CObject::GetRuntimeClass

Syntax

virtual CRuntimeClass* GetRuntimeClass() const;

Remarks

There is one CRuntimeClass structure for each CObject-derived class. The structure members are as follows:

const char* m_pszClassName

A null-terminated string containing the ASCII class name.

int m_nObjectSize

The actual size of the object. If the object has data members that point to allocated memory, the size of that memory is not included.

WORD m_wSchema

The schema number (-1 for nonserializable classes). See the IMPLEMENT_SERIAL macro for a description of schema number.

void (*m_pfnConstruct)(void* p)

A pointer to the default constructor of your class (valid only if the class is serializable).

CRuntimeClass* m_pBaseClass

A pointer to the CRuntimeClass structure that corresponds to the base class.

This function requires use of the IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL macros in the class implementation. You will get incorrect results otherwise.

Return Value

A pointer to the CRuntimeClass structure corresponding to this object's class; never NULL.

Example

CAge a(21);

CRuntimeClass* prt = a.GetRuntimeClass();

ASSERT( strcmp( prt->m_pszClassName, "CAge" ) == 0 );

See Also

CObject::IsKindOf, RUNTIME_CLASS