| description | Learn more about: Dynamic Object Creation | ||||
|---|---|---|---|---|---|
| title | Dynamic Object Creation | ||||
| ms.date | 03/27/2020 | ||||
| helpviewer_keywords |
|
||||
| ms.assetid | 3e0f51cb-3e24-4231-817f-1c0ce9f2d5df |
This article explains how to create an object dynamically at run time. The procedure uses run-time class information, as discussed in the article Accessing Run-Time Class Information.
-
Use the following code to dynamically create an object using the
CreateObjectfunction of theCRuntimeClass. On failure,CreateObjectreturns NULL instead of raising an exception:[!code-cppNVC_MFCCObjectSample#6]