2 added 351 characters in body
source | link

Well, a std::vector<T>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::anystd::any or the more efficient std::variant for thatstd::variant if one knows all the options.
Or one can store pointers, preferably smart-pointers, which generally means (std::unique_ptrstd::unique_ptr or maybeif you actually really need shared ownership std::shared_ptrstd::shared_ptr.

Which alternative is best?
That depends on your specifics, look them over and choose.

Well, a 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 std::variant for that.
Or one can store pointers, preferably smart-pointers (std::unique_ptr or maybe std::shared_ptr.

Which alternative is best?
That depends on your specifics, look them over.

Well, a 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 if one knows all the options.
Or one can store pointers, preferably smart-pointers, which generally means std::unique_ptr or if you actually really need shared ownership std::shared_ptr.

Which alternative is best?
That depends on your specifics, look them over and choose.

1
source | link

Well, a 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 std::variant for that.
Or one can store pointers, preferably smart-pointers (std::unique_ptr or maybe std::shared_ptr.

Which alternative is best?
That depends on your specifics, look them over.