Guest User

Untitled

a guest
Apr 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 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. p1.setVal(5);
  15. p1.makeNull(); // deallocate object #1
  16.  
  17. p1.allocNew(); // allocate object #2
  18. p1.setVal(5);
  19. cout << "p1 Value is " << p1.getVal() << endl; //prints 5
  20.  
  21. p2.allocNew(); // allocate object #3
  22. p2 = p1; // deallocate object #3
  23. p2.setVal(1+p2.getVal());
  24. cout << "p2 Value is " << p2.getVal() << endl; //prints 6
  25.  
  26. p3.allocNew(); // allocate object #4
  27. p1 = p3;
  28. p2.makeNull(); // deallocate object #2
  29. */
  30. }
Add Comment
Please, Sign In to add comment