OK, this is a weird one, and a question that I'd put on comp.lang.c++ except that, like all my questions there, it would turn into a pointless flame war/pissing contest, with a teeny bit of useful content from some people who are mostly on this group anyway.
I want to have something that implements a honkin' big class, which has JUST ONE LITTLE ELEMENT that's implemented as one of several different classes, all descended from a parent class.
There is absolutely no reason why this little element needs to have any of it's functionality visible to the outside world -- so, I'd like to implement it's whole class structure as private sub-classes to my big class:
class CBigClass { public: // etcetera
private:
class CSubClassBase {};
class CBlueSubClass : public CSubClassBase {}; class CRedSubClass : public CSubClassBase {};
// etcetera };
If I do this, the only way that I can see to direct any particular instance of CBigClass to have a particular flavor of CSubClass is with some sort of enum passed to the constructor: BLUE, RED, etc.
This seems untidy to me, but I'll do it that way if no other inspiration comes along.
Can any of you see a way to get this functionality in a way that's (a) cleaner than making an enum and passing it by value to the CBigClass constructor, and (b) keeps all the sub-classes entirely private?
Thanks loads.