M
Martin Stettner
Hi,
I would like to use covariant return types in mutual dependent classes like:
class IB;
class IA {
virtual IB* getIB() = 0;
};
class IB{
virtual IA* getIA() = 0;
};
class B;
class A : public IA{
B *getIB(); /// Here I get an error!
// If I replace with IB * getIB(); everything works fine
};
class B : public IB {
A* getIA();
};
I understand, that the compiler cannot know - at the time of the
declaration of A::getIB() - that B derives from IB. Is there a way to do
some sort of forward declaration with "inheritance information" in order
to get the example to work?
thanks in advance
Martin
I would like to use covariant return types in mutual dependent classes like:
class IB;
class IA {
virtual IB* getIB() = 0;
};
class IB{
virtual IA* getIA() = 0;
};
class B;
class A : public IA{
B *getIB(); /// Here I get an error!
// If I replace with IB * getIB(); everything works fine
};
class B : public IB {
A* getIA();
};
I understand, that the compiler cannot know - at the time of the
declaration of A::getIB() - that B derives from IB. Is there a way to do
some sort of forward declaration with "inheritance information" in order
to get the example to work?
thanks in advance
Martin