1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream> #include <memory> class x{ public: x() { std::cout << "x()" << std::endl; } ~x(){ std::cout << "~x()" << std::endl; } void foo(){ } }; int main(){ std::auto_ptr<x> p_x(new x); p_x->foo(); return 0; }
1 2
x() ~x()