Hello, everyone. I am having a problem with defining a templated class.
I have two header files, String.h, and Object.h. Object.h has a basic
interface that my String class (declared and defined in String.h)
inherits, named "Object". Object.h also has a method in its interface
called "ToString" which returns a String object.
Here is the declaration for Object:
class Object
{
public:
......
virtual String ToString() { return ""; }
};
Obviously, Object.h needs to include "String.h" so it can use the String
type. The String's class is declared like so:
template <typename _CharTraits = char, int _AllocSize = 64> class String
: public Object
{
.......
};
When I try to use String, the compiler tells me that the String type
isn't declared, so I need a way to declare (not define) both String and
Object so they can be used by eachother without any problems. However,
templated classes have to be defined wherever they are declared, and I
have all ready declared the String class.
I want to avoid placing the two classes in the same file (still presents
the same problem), and I want to prevent taking out "ToString" from
Object. Does anybody have any ideas how to work around this problems?
Thanks,
Chris.