samedi 11 mars 2017

Assigning an object to smart pointer from inside [duplicate]

I´m trying to rewrite my old codes so they will be using smart pointers instead of raws, but I encountered this situation:

Some of the objects had an pointer to an pointer attribute like :

Object** _obj;

And from one of its private methods if i wanted to assign it to this obj, i did:

*(_obj) = this;

And that is a problem now, because _obj is now a shared_ptr<Object> . Is there a way how to perform the same behaviour?

Aucun commentaire:

Enregistrer un commentaire