Share via


CObject::IsKindOf

This method tests pClass to see if it is an object of the specified class or it is an object of a class derived from the specified class.

BOOL IsKindOf(
const CRuntimeClass* pClass )
const; 

Parameters

  • pClass
    Specifies a pointer to a CRuntimeClass structure associated with your CObject-derived class.

Return Value

Nonzero if the object corresponds to the class; otherwise it is zero.

Remarks

This method 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.

Example

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 ) ) );

Requirements

**  Windows CE versions:** 1.0 and later  
  Header file: Declared in Afx.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also

CObject::GetRuntimeClass