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;
}
Dick Cheney, Powerful Vice President and Washington Insider, Dies at 84
                      -
                    
A former defense secretary and congressman, he held the nation’s No. 2 job 
under President George W. Bush and was an architect of policies in an era 
of war...
20 minutes ago
  

No comments:
Post a Comment