I try to define a derived class that I would like to use in another derived class, but defining the first one after the second... It works when not bothering with inheritence:
Code:
class class1; //Declaration
class class2
{
private:
class1 *ptr;
......
};
class class1 {...}; //Definition
But as soon as they inherit from a base class, I can't seem to find the good declaration syntax:
Code:
class base
{
public:
base() {}
~base() {}
virtual void uselessFunction() = 0; //Just to make it a base class :)
};
class class1 : public base; //Declaration... doesn't work :(
class class2 : public base
{
private:
class1 *ptr;
public:
void uselessFunction() {}
};
class class1 : public base
{
public:
void uselessFunction() {}
};
I know that my code sample might really seem useless... But I just wanted to keep it simple there... I need to have a "class1" pointer in "class2", and I want to be able to use its "base" methods. I know I can't use the other "class2" methods since the class is defined after, but its base methods should be accessible, isn't it?? I'm using VS 2003... Is there a solution for defining the "class1" with its "public base" specifier?
Thanks!