#include #include #include // auto_ptr<> is deprecated, i know. #pragma GCC diagnostic ignored "-Wdeprecated-declarations" int main() { int *i = new int; std::auto_ptr x(i); std::auto_ptr y; /* Note: auto_ptr is deprecated. */ y = x; std::cout << x.get() << std::endl; // Print NULL assert(x.get() == NULL); std::cout << y.get() << std::endl; // Print non-NULL address i assert(y.get() != NULL); return 0; }