Jump to content

C++ Language/Indirection/SmartPointers/SharedOwnership

From Wikibooks, open books for an open world

Multiple std::shared_ptr<> variables can collectively manage a shared memory allocation, due to built-in reference-counting. C++ will automatically call delete 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)