Original Post
ok is the following bad C++ code, or is it a GNU C++ compiler bug:
template<typename T>
class FunctionFactory
{
public:
class Base;
//more public goodies, some types need Base defined.
private:
//private stuff
public:
class Base
{
public:
//functions
ostream &Print(ostream &str)
{
//call a cirtual method that modifies str
return str;
}
//some virtual functions....
};
//lots more junk...
};
template<typename T>
ostream &operator<<(ostream &ostr, FunctionFactory<T>::Base &obj)
{
return obj.Print(ostr);
}
with the above g++ gives this error message: Quote:is this just a g++ bug in the way it implements templates, or is the above incorrect C++ code for which g++ barfs in its own creative way?
FunctionFactory.hpp:1779: error: ‘class FunctionFactory<T>::Base’ is not a type FunctionFactory.hpp: In function ‘std::ostream& operator<<(std::ostream&, int&)’: FunctionFactory.hpp:1781: error: request for member ‘Print’ in ‘obj’, which is of non-class type ‘int’ make: *** [FunctionFactory] Error 1