std::vector<T> is a dynamic array of
Ts, not of pointers to
Ts or anything else.
So, we need a way to somehow store heterogenous objects.
Well, one can use a
std::any or the more efficient
std::variant for that
std::variant if one knows all the options.
Or one can store pointers, preferably smart-pointers, which generally means (
std::unique_ptr or maybeif you actually really need shared ownership
Which alternative is best?
That depends on your specifics, look them over and choose.