Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include "SmartPointer.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. SmartPointer<Person> p(new Person("Simon", 20));
  9. p->Display();
  10.  
  11. SmartPointer<Person> n(new Person("Mike", 25));
  12.  
  13. n->Display();
  14.  
  15. p.swap(n);
  16. p->Display();
  17. n->Display();
  18. cout << *p << endl;
  19.  
  20. SmartPointer<Person> q;
  21. q = p;
  22. q->Display();
  23. q = n;
  24. q->Display();
  25.  
  26. q.reset();
  27. cout << *q << endl;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement