个人观点: 如果拿鸡蛋作为一个类,那么可以把鸡蛋打碎,可以看到里面什么东西;如果把里面什么东西告诉你,能还原成一个鸡蛋么?这就是动态生成要做的吧
#define DECLARE_DYNCREATE(class_name) /
DECLARE_DYNAMIC(class_name) /
static CObject* PASCAL CreateObject();
CObject* CRuntimeClass::CreateObject()
{
if (m_pfnCreateObject == NULL)
{
TRACE(_T("Error: Trying to create object which is not ")
_T("DECLARE_DYNCREATE /nor DECLARE_SERIAL: %hs./n"),
m_lpszClassName);
return NULL;
}
CObject* pObject = NULL;
TRY
{
pObject = (*m_pfnCreateObject)();
}
END_TRY
return pObject;
}
有了RTTI ,(*m_pfnCreateObject)() 便可以返回正确的类指针。
//
下雨了,收衣服了。
未解决.
石头
2006/08/10