Quick A: Try vector<shared_ptr<boost::any>>.
Recently on SO:
Array of shared pointers to different classes
I am new to c++11 programming and now I'm trying to figure out if it is possible to create an array of shared pointers to different types. For example, something like that:
vector<shared_ptr<**???**>> v; v.push_back(shared_ptr<int>(new int)); v.push_back(shared_ptr<MyClass>(new MyClass()));or any other way to pass
shared_ptrwithout knowing its type.

Add a Comment
Comments are closed.