Smart pointers as class members for polymorphism
问题 I'm new to smart pointers and I would be really grateful if somebody could give me a hint whether the way I'm handling smart pointers as class members is correct. More precisely, the solution that I would like to achieve is in the context of class polymorphism and should be ideally exception-safe. Given a container of heterogeneuous objects ( std::vector<shared_ptr<CBase> > my_vector ), the usual way to add elements is: my_vector.push_back( shared_ptr<CBase>(new CChild(1))) , so that later on