In c++, is it possible to declare inner class (CInner) such that it has outer class (COuter) as its base class ?
This question is about c++ technicalities. Not question of programming style or personal preferences.
Yes. This compiles:
class COuter
{
class CInner;
};
class COuter::CInner : public COuter
{
};
The reason this is required is that a derived class requires that the entire definition be present for its own definition. So you just need to make sure that the outer class is completely defined before the inner class's definition starts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With