I am wondering if you can store items into a vector, using the emplace_back, a type that is derived from the class that vector expects.
For example:
struct fruit
{
std::string name;
std::string color;
};
struct apple : fruit
{
apple() : fruit("Apple", "Red") { }
};
Somewhere else:
std::vector<fruit> fruits;
I want to store an object of type apple inside the vector. Is this possible?