Right. Smart pointers provide semantics of ownership. In particular, the semantics provided by std::shared_ptr are such that the object will be deleted after the destruction of the last shared_ptr pointing to it. shared_ptr stores a reference counter (the number of shared_ptr refers to the object), and when it reaches 0, it deletes the object.
source share