Quote:Original post by Xai
In C++ you pass around the base class pointer and use dynamic_cast to see if it is a derived class object of a certain type (if necessary - which often isn't once the design is cleaned up).
Even then, one could create an object base class from which all objects inherit. Or, better yet, if only a certain amount of classes may be passed as mentioned above, make all of them inherit, directly or indirectly, from a common base class which can then be used.
Also, don't forget:
class A { public: virtual ~A( ) { } };class B { public: virtual ~B( ) { } };// There are situations where this conversion is possible:// An object can exist that is both A and B.B* Frobnicate(A* a) { return dynamic_cast<B*>(a);}