Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 1012 Bytes

File metadata and controls

21 lines (14 loc) · 1012 Bytes

Smart pointers


Smart pointers

  • 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