Covariant return types
From: Martin Stettner (nospam_at_martin.dot.stettner.at.complement.dot.at)
Date: 01/30/05
- Next message: Mike Wahler: "Re: VC++ project crashes in Windows 9x"
- Previous message: Mike Wahler: "Re: [OT, welcome msg] C++ Programmers needed"
- Next in thread: Mike Wahler: "Re: Covariant return types"
- Reply: Mike Wahler: "Re: Covariant return types"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 20:17:49 +0100
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
- Next message: Mike Wahler: "Re: VC++ project crashes in Windows 9x"
- Previous message: Mike Wahler: "Re: [OT, welcome msg] C++ Programmers needed"
- Next in thread: Mike Wahler: "Re: Covariant return types"
- Reply: Mike Wahler: "Re: Covariant return types"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]