This documentation is archived and is not being maintained.

IMPLEMENT_DYNCREATE

Enables objects of CObject-derived classes to be created dynamically at run time when used with the DECLARE_DYNCREATE macro.

IMPLEMENT_DYNCREATE(class_name, base_class_name )

Parameters

class_name
The actual name of the class.
base_class_name
The actual name of the base class.

Remarks

The framework uses this ability to create new objects dynamically, for example, when it reads an object from disk during serialization. Add the IMPLEMENT_DYNCREATE macro in the class implementation file. For more information, see CObject Class Topics.

If you use the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros, you can then use the RUNTIME_CLASS macro and the CObject::IsKindOf member function to determine the class of your objects at run time.

If DECLARE_DYNCREATE is included in the class declaration, then IMPLEMENT_DYNCREATE must be included in the class implementation.

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) 

See Also

MFC Macros and Globals | DECLARE_DYNCREATE | RUNTIME_CLASS | CObject::IsKindOf

Show: