Let's assume you decided to create a hierarchy of non-
CObject derived classes using the
CRuntimeClass of MFC libraries (and
IMPLEMENT_DYNCREATE as well). It is implied that your base class is named like
CXxx (C + class prefix) and all your child classes have names according to the rule: C+ class prefix + kind_name (for example,
CXxxSuper etc.). You need to have a static function
Create(string kind_name) to create objects at runtime and a function
GetKind returning a string with a 'kind_name' of the object.
CRuntimeClass (actually it is a structure), our '
CKindOf...' class exists as
MACROs DECLARE_KIND_OF(class_name) and
IMPLIMENT_KIND_OF(class_name), and every generated 'KindOf' class corresponds with a given class hierarchy.
Using the code
The base class of your hierarchy should use the
And every child class should use
class CXyzCool:public CXyz
class CXyzAdv:public CXyzCool
If your child class is derived directly from the base class (the second level in the class hierarchy), use the '
Base' keyword as the third argument.
And the prefix of the base class otherwise: