Something like this,
The C++ type usually referred to as "smart pointer" is called std::shared_ptr.Code:#include <memory> // class Foo {}; // std::vector<std::shared_ptr<Foo>> m_myVector; // m_myVector.push_back(std::make_shared<Foo>(/* <constructor_parameter_list> */));
std::make_shared is a convenience function that's often used to create std::shared_ptr<> objects.





Reply With Quote
