Sphere: Related Content
#include <iostream>
#include <memory>
using namespace std;
class MyClass {
public:
MyClass() {
cout << "constructing\n";
}
~MyClass(){
cout << "destructing\n";
}
void f() {
cout << "f()\n";
}
};
int main()
{
auto_ptr<MyClass> p1(new MyClass),p2;
auto_ptr<MyClass> p3(p1);
p2 = p1; // transfer ownership
p2->f();
p3->f();
// can assign to a normal pointer
MyClass *ptr = p2.get();
ptr->f();
return 0;
}
Mediacorp music festival Cloud 9 returns at It’s Giving Fest with
performances from Benjamin Kheng, Shazza and more
-
The performances will be held over two evenings on Jul 12 and 13, from 7pm
to 9.30pm at *SCAPE.
36 minutes ago
No comments:
Post a Comment