Guest User

Untitled

a guest
Apr 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2. #include<iostream>
  3. #include<string>
  4. using namespace std;
  5.  
  6. #include "RefCountT.cpp"
  7. #include "RefCountPtrT.cpp"
  8.  
  9.  
  10. int main() {
  11.  
  12. RefCountPtrT<int> p1, p2, p3;
  13. p1.allocNew(); // allocate object #1
  14.  
  15.  
  16.  
  17. p1.setVal(53);
  18. cout << p1.getVal() << endl;
  19.  
  20.  
  21. /*
  22. p1.makeNull(); // deallocate object #1
  23.  
  24. p1.allocNew(); // allocate object #2
  25. p1.setVal(5);
  26. cout << "p1 Value is " << p1.getVal() << endl; //prints 5
  27.  
  28. p2.allocNew(); // allocate object #3
  29. p2 = p1; // deallocate object #3
  30. p2.setVal(1+p2.getVal());
  31. cout << "p2 Value is " << p2.getVal() << endl; //prints 6
  32.  
  33. p3.allocNew(); // allocate object #4
  34. p1 = p3;
  35. p2.makeNull(); // deallocate object #2
  36. */
  37.  
  38. }
Add Comment
Please, Sign In to add comment