1 class RefCountedBase { 2 protected: derefBase()3 bool derefBase() 4 { 5 return true; 6 } 7 }; 8 9 template<typename T> class RefCounted : public RefCountedBase { 10 public: deref()11 void deref() 12 { 13 if (derefBase()) 14 delete static_cast<T*>(this); 15 } 16 17 protected: 18 // RefCounted() { } ~RefCounted()19 ~RefCounted() 20 { 21 } 22 }; 23 24 25 class Event : public RefCounted<Event> { 26 public: 27 Event(); 28 virtual ~Event(); 29 }; 30