Browse - programming tips - smart pointerDate: 2008may6 Q. Which "smart pointer" should I use? A. I prefer STL's auto_ptr Example 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. Add a commentSign in to add a comment |