CWnd* pWnd = new CWnd(); if (pWnd->IsKindOf(RUNTIME_CLASS(CWnd))) { // pWnd is an instance of CWnd class or its subclass }
class CMyWnd : public CWnd {}; CMyWnd* pMyWnd = new CMyWnd(); if (pMyWnd->IsKindOf(RUNTIME_CLASS(CWnd))) { // pMyWnd is an instance of CWnd class or its subclass // Note that this condition will always be true } if (pMyWnd->IsKindOf(RUNTIME_CLASS(CMyWnd))) { // pMyWnd is an instance of CMyWnd class }These examples use the MFC library for creating and manipulating windows in a C++ application.