Advertisement
soandos

Untitled

Nov 28th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include "Sptr.hpp"
  2.  
  3. class A
  4. {
  5.     public:
  6.     int a;
  7.     int* b;
  8.     A( int i)
  9.     {
  10.         b = new int(i);
  11.     }
  12.     ~A()
  13.     {
  14.         delete b;
  15.     }
  16.     A() = delete;
  17. };
  18.  
  19. using namespace cs540;
  20.  
  21. int main()
  22. {
  23.     Sptr<A> a(new A(1));
  24.     Sptr<A> b(new A(2));
  25.  
  26.     int a1 = *(a.refcount);
  27.     int b1 = *(b.refcount);
  28.  
  29.     a = b;
  30.     a1 = *(a.refcount);
  31.     b1 = *(b.refcount);
  32.     int test;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement