Home | Overview | How Do I | FAQ
This article explains how to create an object dynamically at run time. The procedure uses run-time class information, as discussed in the article CObject Class: Accessing Run-Time Class Information.
To dynamically create an object given its run-time class
CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CMyClass );
CObject* pObject = pRuntimeClass->CreateObject();
ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CMyClass ) ) );