diff --git a/auto_ptr.cpp b/auto_ptr.cpp new file mode 100644 index 0000000..a60fcae --- /dev/null +++ b/auto_ptr.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +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; +}