H
Heiner
Hi!
The following snippet
class B;
class A
{
public:
virtual B * getB();
};
class B
{
public:
virtual A * getA();
};
defines 2 classes. Both return pointer to each other. class A compiles
only, because B is forward declared (by class B
Now I would like to derive from them:
class DA : public A
{
public:
// virtual DB * getB(); <- does not compile
};
class DB : public B
{
public:
virtual DA * getA();
};
Unfortunately I can not get the getB() compiled. A simple forward
declaration (class DB gives a:
gcc main.cpp -o test
main.cpp:20: error: invalid covariant return type for `virtual DB* DA::getB()'
main.cpp:6: error: overriding `virtual B* A::getB()'
Question: Is there a forward declaration, which shows the compiler the
inheritance as well; something like a
class DB : public B;
(which does not work)?
The following snippet
class B;
class A
{
public:
virtual B * getB();
};
class B
{
public:
virtual A * getA();
};
defines 2 classes. Both return pointer to each other. class A compiles
only, because B is forward declared (by class B
Now I would like to derive from them:
class DA : public A
{
public:
// virtual DB * getB(); <- does not compile
};
class DB : public B
{
public:
virtual DA * getA();
};
Unfortunately I can not get the getB() compiled. A simple forward
declaration (class DB gives a:
gcc main.cpp -o test
main.cpp:20: error: invalid covariant return type for `virtual DB* DA::getB()'
main.cpp:6: error: overriding `virtual B* A::getB()'
Question: Is there a forward declaration, which shows the compiler the
inheritance as well; something like a
class DB : public B;
(which does not work)?