C++ Language/Indirection/SmartPointers/PointerToBaseClass

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

The pointer-type managed by a smart pointer can be a base class of the actual memory allocation (i.e., std::unique_ptr<CRBase> poUnique(new CRDerived);).

Additional information about using smart pointers in a class hierarchy (includes interactive examples)