KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Are there any differences between the two pieces of code below? Is any of them preferable to the other? operator= boost::shared_ptr<Blah> foo; // foo.ptr should be NULL foo = boost::shared_ptr<Blah>(new Blah()); // Involves creation and copy of a shared_ptr? reset boost::shared_ptr<Blah> foo; // foo.ptr should be NULL foo.reset(new Blah()); // foo.ptr should point now to a new Blah object Note: I need to define the shared_ptr and then set it in a different line because I'm using it in a piece of code like: boost::shared_ptr<Blah> foo; try { foo.reset... } foo...
Tags (comma-separated)
Save Edits
Cancel