Smart pointer
In computer programming, a smart pointer is a pointer that keeps track of the pointer object for the purpose of memory management.
Pointer usage is a major source of bugs: the constant allocation, deallocation and referencing that must be performed by a program written using pointers makes it very likely that some memory leaks will occur.
Smart pointers try to prevent the memory leaks making the deallocation function automatic: when the pointer to an object (or the last in a series of pointers) is destroyed, for example because it goes ouside of scope, the pointed object is destroyed too.
Several types of smart pointers exist. Some works with reference counting, others assigning onwership of the object to a single pointer.
See also: Garbage collection