Smart Pointer

From OSDev.wiki
Revision as of 08:32, 29 March 2011 by Creature (talk | contribs) (Provided basic article regarding smart pointers, feel free to correct or edit.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A smart pointer is a datatype simulating a pointer, providing extra features in its implementation.

Definition

A smart pointer is in fact very similar to a standard pointer. It is usually wrapped within a class where it can provide additional functionality. One of the features smart pointers can offer is automatic garbage collection. Some smart pointers automatically free the memory associated with it when the destructor is called. This may sometimes involve a reference counter that keep tracks of how many instances of the class point to the same object. This makes smart pointers especially interesting for automatic garbage collection and protection against memory leaks.

See Also

Articles