Smart pointers are
objects which store pointers to dynamically allocated (heap) objects. They
behave much like built-in C++ pointers except that they automatically delete
the object pointed to at the appropriate time. Smart pointers are particularly
useful in the face of exceptions as they ensure proper destruction of dynamically
allocated objects. They can also be used to keep track of dynamically allocated
objects shared by multiple owners. Conceptually, smart pointers are seen
as owning the object pointed to, and thus responsible for deletion of the
object when it is no longer needed.
Give
feedback of this article