admin管理员组

文章数量:1636900

IMPLEMENT_DYNCREATE

This   macro   must   appear   in   the   implementation   file   for   any   class   that   uses   DECLARE_OLECREATE.   
    
The   external   name   is   the   identifier   exposed   to   other   applications.   Client   applications   use   the   external   name   to   request   an   object   of   this   class   from   an   automation   server.   
    
The   OLE   class   ID   is   a   unique   128-bit   identifier   for   the   object.   It   consists   of   one   long,   two   WORDs,   and   eight   BYTEs,   as   represented   by   l,   w1,   w2,   and   b1   through   b8   in   the   syntax   description.   ClassWizard   and   AppWizard   create   unique   OLE   class   IDs   for   you   as   required.  

Parameters

class_name

派生类名.

base_class_name

基类名.

Remarks

框架使用这种技巧动态的创建新的对象。如,序列化时,从盘中读一个对象。在类实现的文件中添加宏IMPLEMENT_DYNCREATE. For more information, see .

如果你使用了DECLARE_DYNCREATE 和 IMPLEMENT_DYNCREATE 宏, 你可以使用RUNTIME_CLASS 宏和 CObject::IsKindOf 成员函数去决定是否在运行时中创建宏.

如果类声明的文件中包含有DECLARE_DYNCREATE, 类实现的文件中必须有 IMPLEMENT_DYNCREATE.

Example

/* CAge.h */

class CAge : public CObject

{

     int num;

public:

     DECLARE_DYNCREATE(CAge)

};

//==============

/* CAge.cpp */

#include "stdafx.h"

#include "CAge.h"

IMPLEMENT_DYNCREATE(CAge, CObject)

本文标签: IMPLEMENTDYNCREATE