Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- #include "RefCountT.cpp"
- #include "RefCountPtrT.cpp"
- int main() {
- RefCountPtrT<int> p1, p2, p3;
- p1.allocNew(); // allocate object #1
- p1.setVal(53);
- cout << p1.getVal() << endl;
- /*
- p1.makeNull(); // deallocate object #1
- p1.allocNew(); // allocate object #2
- p1.setVal(5);
- cout << "p1 Value is " << p1.getVal() << endl; //prints 5
- p2.allocNew(); // allocate object #3
- p2 = p1; // deallocate object #3
- p2.setVal(1+p2.getVal());
- cout << "p2 Value is " << p2.getVal() << endl; //prints 6
- p3.allocNew(); // allocate object #4
- p1 = p3;
- p2.makeNull(); // deallocate object #2
- */
- }
Add Comment
Please, Sign In to add comment