Programming Tips - C++: How can I use auto_ptr

Date: 2008may6 Language: C++ Keywords: smart pointer Q. C++: How can I use auto_ptr A. Now unique_ptr is prefered over auto_ptr Example auto_ptr use:
#include <memory> class Thing { int a; int b; }; main() { std::auto_ptr<Thing> a(new Thing); std::auto_ptr<Thing> b; b = a; // Now b owns the Thing } // a and b are delete-ed when they go out of scope (here)
Using automatic (ie stack) variables is even better.