铁路论文:在C++中怎样实现 IsKindOf()
来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 12:57:11
a必须要继承自CObject,还要加DECLARE_DYNAMIC
Call the IsKindOf member function for objects of that class, using the RUNTIME_CLASS macro to generate the CRuntimeClass argument, as shown here:
// in .H file
class CPerson : public CObject
{
DECLARE_DYNAMIC( CPerson )
public:
CPerson(){};
// other declaration
};
// in .CPP file
IMPLEMENT_DYNAMIC( CPerson, CObject )
void SomeFunction(void)
{
CObject* pMyObject = new CPerson;
if(pMyObject->IsKindOf( RUNTIME_CLASS( CPerson ) ) )
{
//if IsKindOf is true, then cast is all right
CPerson* pmyPerson = (CPerson*) pMyObject ;
...
delete pmyPerson;
}
...
delete [MyObject];
}
Call the IsKindOf member function for objects of that class, using the RUNTIME_CLASS macro to generate the CRuntimeClass argument, as shown here:
// in .H file
class CPerson : public CObject
{
DECLARE_DYNAMIC( CPerson )
public:
CPerson(){};
// other declaration
};
// in .CPP file
IMPLEMENT_DYNAMIC( CPerson, CObject )
void SomeFunction(void)
{
CObject* pMyObject = new CPerson;
if(pMyObject->IsKindOf( RUNTIME_CLASS( CPerson ) ) )
{
//if IsKindOf is true, then cast is all right
CPerson* pmyPerson = (CPerson*) pMyObject ;
...
delete pmyPerson;
}
...
delete [MyObject];
}
在C++中怎样实现 IsKindOf()
怎样在jsp中实现打印功能1
梦在追求中实现
嵌入式系统中FFT算法研究与实现(C语言)
在服务大局中实现大发展
在电脑中实现真人笔迹签名
在Scrum中实现敏捷建模
在电脑中实现真人笔迹签名
在电脑中实现真人笔迹签名
张维迎:道德只能在市场中实现
在"简单比较"中实现持续盈利
在追求中实现本色自我
在电脑中实现真人笔迹签名
在电脑中实现真人笔迹签名
在企业发展中实现自我价值
在C#程序中实现插件架构
在C\\C++中嵌入汇编
长期股权投资在权益法下,未实现的内部交易怎样被体现在相关资产账面价值中,而应该将其从合营企...
C/C++中怎样获取日期和时间(
怎样在地震中逃生?
怎样在社会中生存
怎样在方框中打钩?
怎样在excel里实现msgbox数据值报警?
11嵌入式系统中FFT算法研究与实现(C语言)