Store different derived classes in collections in C++ and C#: CoVariance, shared_ptr, unique_ptr

I wanted to create a collection container that would hold objects of various types, all derived from a common interface/base class.In C# and VB, this is easy. Just create a new List<MyBase>() and add elements to it, including various MyBase derived typesAdding elements that are more derived is Covariance (not to be confused with covariance…

0