C++ Language/Indirection/SmartPointers/OwningAnArray

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A smart pointer can own an array (e.g., std::unique_ptr<int[]> piUnique(new int[32]);). When the time comes, it will use the correct destructor (delete[]).

Additional information about smart pointers owning an array (includes interactive examples)