+ 2
What is the smart pointer in C++?
What is this?
4 Respuestas
+ 3
Thanks)
+ 2
So it is an object-wrapper? And releasing of memory happens because of narrowed scopes?
+ 1
the smart pointer like when there is no referance to it well be released from the heap
examlpe:
int *p = new int(5); // no. of ref to p is 1
int temp = *p; // no. of ref to p is 2
temp = 4; // no. of ref to p is 1
p = NULL; : // there is no referance to p
// anymore... released safly
(but of course it well be little bit more complicated)
+ 1
yeah it also consider the method or the object scope
it's just to privant memory leaks
you may forget to release resources thats lead to memory leak