How to handle RTTI in MFC ?



How to handle RTTI in MFC ?..

Answer / n.venkateshwara rao.

RTTI (Run Time Type Identification) in MFC can be handled
by using the class CRunTimeClass.

But CRunTimeClass can be use to identify the type of the
class which are derived from CObject.

For eg -

void MyFunction()
{
CObject *mObject = new MyClass;
if(mObject->IsKindOf(RUNTIME_CLASS( MyClass) ) )
{
printf("Class is of type MyClass\n");
}
else
{
printf("Class is of type someotherclass\n");
}
}

We can use "type_info" for other type of classes which are
not derived from CObject.

Is This Answer Correct ?    15 Yes 1 No

Post New Answer

More MFC Interview Questions

Explain StretchBlt and BitBlt

1 Answers  


What four types of properties are supported by an ActiveX control?

1 Answers  


Will there be any difference in the image buffer size if it is loaded in from CString to LPTSTR using GetBuffer()? lptstr = string.GetBuffer(0);

2 Answers  


what is the size of a process

2 Answers   E Logic, IBM,


1) How do you Destroy a Dialog Box ?

2 Answers   Honeywell,


What are the advantages of using Doc/View or SDI over DialogBox

2 Answers  


What is the base class for MFC Framework ?

2 Answers   Mphasis,


what is the difference between SDI and MDI

15 Answers   CMC, HCL, Siemens,


1)How to create ToolTip in MFC?

2 Answers  


what is functioning of DIalodDataXchange ..?

1 Answers  


Differ GetMessage, PostMessage & PeakMessage?

4 Answers   Symphony,


How do you change the properties for a tree view control that is part of the CTreeView class?

1 Answers  


Categories