I am just getting started to work with boost::shared_ptr
so I have searched around and I see that there are several ways of initializing it:
boost::shared_ptr<MyClass> myclass = boost::shared_ptr<MyClass>(new MyClass());
boost::shared_ptr<MyClass> myclass = new MyClass();
boost::shared_ptr<MyClass> myclass = boost::make_shared<MyClass>();
And of assigning it:
boost::shared_ptr<MyClass> someOtherType::getMyClass();
boost::shared_ptr<MyClass> myclass = someOtherTypePointer->getMyClass();
boost::shared_ptr<MyClass> myclass = boost::make_shared<MyClass>(someOtherTypePointer->getMyClass());
Which one would be the preferred way for the init/assign and why?
Thank you.