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

What function is used to disable a control at runtime?

7 Answers  


How to handle RTTI in MFC ?

1 Answers  


1)why we cant create more than one instance of the class Derived from CWinApp

5 Answers   Alstom,


How can server communicate with more than one client

2 Answers   Invensys,


How we can findout Memoryleaks, In what way it can be avoided

6 Answers   Infosys,






1)At run-time, you can change the icon by calling the LoadIcon() function?

2 Answers  


is there any class which is not derived from Cobject

11 Answers   Patni,


Which MFC function is used to display output?

9 Answers   TCS,


How can we create thread in MFC framework?

3 Answers  


what is the use of AFX_MANAGE_STATE ?

4 Answers   HCL,


What is socket?

3 Answers  


How to handle dynamic menus in mfc? What happens when client calls cocreateinstance?

0 Answers  


Categories