CObject::IsKindOf
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

CObject::IsKindOf 

Tests this object's relationship to a given class.


BOOL IsKindOf(
   const CRuntimeClass* pClass 
) const;

Parameters

pClass

A pointer to a CRuntimeClass structure associated with your CObject-derived class.

Nonzero if the object corresponds to the class; otherwise 0.

This function tests pClass to see if (1) it is an object of the specified class or (2) it is an object of a class derived from the specified class. This function works only for classes declared with the DECLARE_DYNAMIC, DECLARE_DYNCREATE, or DECLARE_SERIAL macro.

Do not use this function extensively because it defeats the C++ polymorphism feature. Use virtual functions instead.

See CObList::CObList for a listing of the CAge class used in all CObject examples.

// example for CObject::IsKindOf
CAge a(21);  // Must use IMPLEMENT_DYNAMIC, IMPLEMENT _DYNCREATE, or
             // IMPLEMENT_SERIAL
ASSERT( a.IsKindOf( RUNTIME_CLASS( CAge ) ) );
ASSERT( a.IsKindOf( RUNTIME_CLASS( CObject ) ) );
Show:
© 2016 Microsoft