@retated : [[CPlusPlus]] [[STL]] ==== C++ autopointers==== template class auto_ptr { T* ptr; public: explicit auto_ptr(T* p = 0) : ptr(p) {} ~auto_ptr() {delete ptr;} T& operator*() {return *ptr;} T* operator->() {return ptr;} // ... }; #include std::auto_ptr v; http://ootips.org/yonat/4dev/smart-pointers.html Also in STL : std:auto_ptr http://www.cerfacs.fr/Info/doc/Compilateurs/sunone7/mr/man3c++/auto_ptr.3.html http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/MEMORY_AUTO_PTR.asp