C++ Language/Indirection/SmartPointers/SharedOwnership

Multiple  variables can collectively manage a shared memory allocation, due to built-in reference-counting. C++ will automatically call  on the underlying memory once all of the smart pointer variables have released their shared-ownership of it.

Additional information about shared_ptr (includes interactive examples)