b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

implement_dyncreate_on_cbn_editchange_cbrush(3)

电脑杂谈  发布时间:2017-01-13 02:03:22  来源:网络整理

首先来看“AFX_COMDAT const CRuntimeClass class_name::class##class_name = {#class_name, sizeof(class class_name), wSchema, pfnNew, &class_name::_GetBaseClass, NULL, class_init }; ”语句,给之前在DECLARE_DYNAMIC里定义的CRuntimeClass类型的静态成员变量赋。

“CRuntimeClass* class_name::GetRuntimeClass() const { return _RUNTIME_CLASS(class_name); }”语句很简单,就一个return语句,是之前在DECLARE_DYNAMIC里定义的GetRuntimeClass的实现。下面再来看看其中嵌套使用的 RUNTIME_CLASS 宏定义:

#define _RUNTIME_CLASS(class_name) ((CRuntimeClass*)(&class_name::class##class_name))
#ifdef _AFXDLL
#define RUNTIME_CLASS(class_name) (class_name::GetThisClass())
#else
#define RUNTIME_CLASS(class_name) _RUNTIME_CLASS(class_name)
#endif

这部分之所以单独define出一个宏,主要是为了方便从某个指定的class直接得到它的CRuntimeclass静态成员。

最后来看CRuntimeClass,CRuntimeClass没有基类。每个由CObject派生的类都与一个CRuntimeClass结构相联系,用户可以使用该结构获取一个对象及其基类的运行时信息。当需要额外的函数参数检查时,或当用户必须根据一个对象的类编写特殊目的代码时,在运行时确定该对象的类就非常有用。C并不直接支持运行时类的信息。

在MFC中CObject::IsKindOf( const CRuntimeClass* pClass ) 利用CRuntimeClass来进行判定,如果你生成的类是以CObject为基础的,你可以使用该成员函数来判定。下面举一个参考来的例子来加深了解CRuntimeClass,以及那几个宏的作用。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-25930-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...