Original Post
Lets say I have a base class, 'Widget'. What I want to be able to do create several objects of different types, which are all derived from 'Widget', and be able to store them in an array (or other suitable container class). Is this possible, and if not, are there any suitable workarounds? Example: I know its possible to pass a derived class into a function instead of the parent class, I just dont know how to apply this to another situation, such as this one. PS: I apologise if my wording is incorrect.
class Base
{};
class One: public Base
{};
class Two: public Base
{};
One X;
Two Y;
std::vector<Base> Storage;
Storage.push_back(X);
Storage.push_back(Y);