We can do it on unique pointer. But how to do it on shared pointer? If I do reset, the memory is deleted.
shared_ptr<int> p(new int(10));
int* q = p.release(); //???
We can do it on unique pointer. But how to do it on shared pointer? If I do reset, the memory is deleted.
shared_ptr<int> p(new int(10));
int* q = p.release(); //???
You can't do it, because there can be other shared_ptr<int>
objects referring to the same int
.