Advertisement
coder0xff

C++ Objects

Aug 31st, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include "Object.h"
  2.  
  3. // The ObjectTest class inherits the universal-base-class Object
  4. class ObjectTest : OBJECT
  5. {
  6. // OBJECT_THIS makes Ref, ConstRef, WeakRef, and ConstRef for shared_pointers
  7. // and adds This() and WeakThis() methods that return shared pointers
  8. OBJECT_THIS(ObjectTest);
  9. public:
  10.     ObjectTest(int)
  11.     {
  12.         //It's now OK to get a shared pointer in a constructor!!!
  13.         This();
  14.     }
  15. };
  16.  
  17. //ObjectTest::Ref is a shared pointer
  18. ObjectTest::Ref test = OBJECT_NEW ObjectTest(5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement