I came across this code.
class SomeClass::OtherClass : public BaseClass
{
// stuff in here
}
SomeClass is a class, so maybe OtherClass is a class that exists inside the scope of SomeClass? I've just never seen it done this way.
So, is that what it means?
maybe OtherClass is a class that exists inside the scope of SomeClass?
Give yourself a checkmark. That is what it means.
This is used to subsequently define OtherClass
after it was declared inside SomeClass
:
class SomeClass {
class OtherClass;
OtherClass* GetOtherClassInstance() { ...}
};
class SomeClass::OtherClass {
}
One might do this if the inner class only makes sense in the context of the exterior class.
class Vector {
class Iterator;
Iterator* GetStart();
};
class Vector::Iterator {
details.
}
As mentioned elsewhere, the pimpl idiom is an excellent use of inner classes with deferred definition.
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