共用方式為


CRuntimeClass Structure

Each class derived from CObject is associated with a CRuntimeClass structure that you can use to obtain information about an object or its base class at run time.

struct CRuntimeClass

Members

Public Methods

Name

Description

CRuntimeClass::CreateObject

Creates an object during run time.

CRuntimeClass::FromName

Creates an object during run time using the familiar class name.

CRuntimeClass::IsDerivedFrom

Determines if the class is derived from the specified class.

Public Data Members

Name

Description

CRuntimeClass::m_lpszClassName

The name of the class.

CRuntimeClass::m_nObjectSize

The size of the object in bytes.

CRuntimeClass::m_pBaseClass

A pointer to the CRuntimeClass structure of the base class.

CRuntimeClass::m_pfnCreateObject

A pointer to the function that dynamically creates the object.

CRuntimeClass::m_pfnGetBaseClass

Returns the CRuntimeClass structure (only available when dynamically linked).

CRuntimeClass::m_wSchema

The schema number of the class.

Remarks

CRuntimeClass is a structure and therefore does not have a base class.

The ability to determine the class of an object at run time is useful when extra type checking of function arguments is needed, or when you must write special-purpose code based on the class of an object. Run-time class information is not supported directly by the C++ language.

CRuntimeClass provides information on the related C++ object, such as a pointer to the CRuntimeClass of the base class and the ASCII class name of the related class. This structure also implements various functions that can be used to dynamically create objects, specifying the type of object by using a familiar name, and determining if the related class is derived from a specific class.

For more information on using CRuntimeClass, see the article Accessing Run-Time Class Information.

Inheritance Hierarchy

CRuntimeClass

Requirements

Header: afx.h

See Also

Reference

Hierarchy Chart

CObject::GetRuntimeClass

CObject::IsKindOf

RUNTIME_CLASS

IMPLEMENT_DYNAMIC

IMPLEMENT_DYNCREATE

IMPLEMENT_SERIAL