Not auto_ptr. std::unique_ptr/std::shared_ptr.
Anyway, to answer your question, here's an example of something:
Now remember that you can generalize this to any type, not just int.Code:int x = 0; int * y = new int(5); int * z = new int (10); std::cout << x << " " << *y << " " << *z << "\n"; x = *y; *z = x; *y = *z; std::cout << x << " " << *y << " " << *z << "\n"; delete y; delete z;