Original Post
Hi, I have a base class named BasePrimitive and two other classes named Rectangle & Circle which are derived from BasePrimitive class. Basically what I am trying to do is to store Circle and Rectangle objects in a common container. (std::vector shapeList). There is no problem when using push_back to store these objects. However I cannot retrieve these objects back because I cannot type cast them. (BasePrimitive class has a type enumeration and I am trying to type cast wrt to its value) I have tried all type casting methods I know including, dynamic_cast & reinterpret_cast, but it didnt help. Is there a way to type cast or is there a way around this problem in C++. (I know I can use union but, I'd rather prefer a neater C++ way of solution since inheritance is involved ;) ) Thanks for your help..