#include #include using namespace hgl; class DebugObject:public Object { HGL_OBJECT_CLASS_BODY(DebugObject) public: void Initailize() { std::cout<<"DebugObject::Initailize("< HGL_DEFINE_DEFAULT_OBJECT_MANAGER(DebugObject); #include int main() { SafePtr obj1=HGL_NEW_OBJECT(DebugObject); HGL_DEFINE_OBJECT(DebugObject,obj2); //等于上一行 // DebugObject *obj3=new DebugObject(); //编译不过(构造函数被定义为私有) obj1.Release(); //delete obj2; //编译不过,SafePtr<>不能被delete if(obj1.IsValid()) { std::cerr<<"[ERROR] obj1 IsValid() error!"<GetSerialNumber(); SafePtr obj2_indirect=GetObjectBySerial(obj2_sn); //直接根据序列号获取对象 if(!obj2_indirect.IsValid()) { std::cerr<<"[ERROR] obj2_indirect isn't valid!"<