Thread: expression error?

  1. #1
    Registered User trekker's Avatar
    Join Date
    Mar 2002
    Posts
    46

    Question expression error?

    I've really stuck on this error.
    Here's the code:

    file : Foo.h
    Code:
    #ifndef FOO
    #define FOO
    
    // class declaration
    
    template <class T>
    class Foo {
    	public:
    		Foo( void );
    		
    		int foo( void ) const;
    		
    		~Foo();
    };
    
    
    // class definition
    
    template <class T>
    Foo<T>::Foo( void )
    {return;}
    
    
    template <class T>
    int Foo<T>::foo( void ) const
    {return 0;}
    
    
    template <class T>
    Foo<T>::~Foo()
    {return;}
    
    #endif
    file : Foo2.h

    Code:
    #include "Foo.h"
    
    #ifndef FOO2
    #define FOO2
    
    // class declaration
    
    template <class T>
    class Foo2 {
    	public:
    		Foo2( void );
    		
    		Foo<T> foo2( void ) const;
    		
    		~Foo2();
    };
    
    // class definition
    
    template <class T>
    Foo2<T>::Foo2( void )
    {return;}
    
    template <class T>
    Foo<T>
    Foo2<T>::foo2( void ) const
    {return Foo<T> f();}
    
    template <class T>
    Foo2<T>::~Foo2( void )
    {return;}
    
    #endif
    and the main.cpp file:

    Code:
    #include "Foo.h"
    #include "Foo2.h"
    
    int main( void ) {
    Foo2<int> foo2();
    Foo<int> foo = foo2.foo2(); // expression error!!!!!!
    	
    	return 0;
    }
    any help would be appreciated...
    to boldy code where...

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    Code:
    template <class T>
    Foo<T> Foo2<T>::foo2( void ) const
    {
    	return Foo<T>();
    }
    ...
    int main( void ) {
    	Foo2<int> foo2;//<-- no ()
    	Foo<int> foo = foo2.foo2();

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    What exactly are you trying to accomplish?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User trekker's Avatar
    Join Date
    Mar 2002
    Posts
    46
    It's not really important.
    Foo2 is supposed to construct Foo objects
    from a file.

    Java programming corrupts...
    to boldy code where...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM