00001 #ifndef INIT_VTABLES_H 00002 #define INIT_VTABLES_H 00003 00006 00051 class VirtBase 00052 { 00053 protected: 00055 00058 class Init 00059 { 00060 public: 00062 00063 Init():p(NULL){} 00065 00066 ~Init(){ 00067 if(p) 00068 p->ctor(); 00069 } 00071 00072 void reg(VirtBase* _p)const{ 00073 p=_p; 00074 } 00075 private: 00076 mutable VirtBase* p; 00077 }; 00078 friend class Init; 00079 virtual void ctor()=0; 00080 VirtBase(const Init& init){ 00081 init.reg(this); 00082 } 00083 }; 00084 00085 #endif