Hello,
It's late, I'm really tired but there's now something stuck in my head which is nagging me so I think I'd better share it and hopefully get some rest.
I don't have much experience with C++, so I don't know if it does this explicitly. I also don't know what the name of this technique would be, so I can't search for it. Anyway...
Suppose you had a base class like:-
So, the class contains three pointers which can point to instances of the same class.Code:// code might be wrong, again I don't usually do C++ class CBaseClass { static CBaseClass *m_pClassPtr1; static CBaseClass *m_pClassPtr2; static CBaseClass *m_pClassPtr3; };
But what if I then wanted to derive a class from that:-
Instantiating CAnotherClass would give me an object with three pointers to instances of CBaseClass.Code:class CAnotherClass : public CBaseClass { // additonal member variables and methods };
What I would like to know is this: is there a way of specifying it so that m_pClassPtr1, 2 and 3 are always pointers to instances of the derived class, whatever that may be? If not in C++ in another language perhaps?
It just crossed my mind that it should certainly be feasible...