Smart pointers

Smart pointers are a special kind of classes that behave like ordinary pointers but have the very desirable property of automatically keeping an internal counter of how many references exist (throughout the entire program) to each object, automatically deleting it when there are no active references. The following figure illustrates the internal memory structure of a pair of smart pointers which actually are aliases of one single object:

smart pointers

More details on smart pointers and all their methods are given in the chapter “Smart pointers” in the MRPT book.