Hello,

 

I have a class that stores a private member a shared_ptr<T> that points to a dynamically allocated instance of T.

A getter member function returns T&.

 

I now realise that in a snippet, I would like to store a new shared_ptr<T> to that returned object.

     T& t = myinstance.getT();

I would like to store t in a shared_ptr, ie increment the count of shared pointers

Do I do:

    shared_ptr<T> desiredPointer( &t  );

 

will this increment the count of shared pointers to t?

 

Regards,