I know the title sounds familiar as there are many similar questions, but I\'m asking for a different aspect of the problem (I know the difference between having things on t
Firstly you have an error in the code, you mean to have Thing *thing(new Thing());
, and only return thing;
.
shared_ptr
. Deref it as tho it was a pointer. It will be deleted for you when the last reference to the Thing
contained goes out of scope.