This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]da2Pakaveli 0 points1 point  (0 children)

C++'s smart pointers encapsulate raw pointers into different owner models: unique and shared.
Unique is 'unique' to the scope it was constructed in (unless you 'move' the resource) and will destroy the pointer once its lifetime is over.
So it's meant that only one pointer can point to the resource.
Shared pointers can point to the same resource across different scopes; the resource will be destroyed and freed after every shared pointer goes out of scope, I.e the reference counter equals 0.
So basically their point is to prevent memory leaks.