C
Charles Jamieson
I have two classes, a base class, CBaseClass, and its derived class,
CDerivedClass.
I overload the insertion operator as
ostream& operator << ( ostream&, CBaseClass& );
Then I define an object as
CDerivedClass object;
I then have the line
std::cout << object;
When I compile and link this code (using gcc 3.3.3), I get the following
error message
undefined reference to `operator<<(std::basic_ostream<char,
std::char_traits<char> >&, CDerivedClass&)'
How can I get the compiler to use the overloaded insertion operator as I
defined it?
-charles
CDerivedClass.
I overload the insertion operator as
ostream& operator << ( ostream&, CBaseClass& );
Then I define an object as
CDerivedClass object;
I then have the line
std::cout << object;
When I compile and link this code (using gcc 3.3.3), I get the following
error message
undefined reference to `operator<<(std::basic_ostream<char,
std::char_traits<char> >&, CDerivedClass&)'
How can I get the compiler to use the overloaded insertion operator as I
defined it?
-charles