-
A smart pointer manages a pointer to a heap allocated object
- Deletes the pointed-to object at the right time
-
operator->()calls managed object methods -
operator.()calls smart pointer methods - smart pointer to a base class can hold a pointer to a derived class
-
STL smart pointers:
-
std::unique_ptr<> -
std::shared_ptr<> -
std::weak_ptr<> -
std::auto_ptr<>- removed in C++17
-