#include <iostream>
#include <memory>
using namespace std;
class MyClass {
public:
MyClass() {
cout << "constructing\n";
}
~MyClass() {
cout << "destructing\n";
}
void f() {
cout << "Inside f()\n";
}
};
int main()
{
auto_ptr<MyClass> myClassPointer1(new MyClass), myClassPointer2;
myClassPointer2 = myClassPointer1;
myClassPointer2->f();
MyClass *ptr = myClassPointer2.get();
ptr->f();
return 0;
}
|