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 is message loop how mfc does it internally?

4 Answers   Aspire,


How to access document object from view ?

1 Answers  


In VC++ How to transfer between one exe to another exe while running..

5 Answers   Wipro,


How we call a dialog in another dialog?

2 Answers  


Explain about MDI and CMultiDocTemplate ?

2 Answers  






how can u change button shape at run time

3 Answers   Samsung,


How to setup a timer?

3 Answers   IBM,


Hi can anyone explain about the synchronization objects types and where we are using in the code.

1 Answers  


I have 2 threads. One thread prints odd numbers and the second thread prints even numbers. Now, I have to execute the threads alternatively so that i can output 1,2,3,4,5,6,..... write code for this?

1 Answers  


Which Macro is a Super set of other two macro DECLARE_SERIAL,DECLARE_DYNAMIC and DECLARE_DYNCREATE. ?

2 Answers   Sony,


what is the updated verssion in vc++

3 Answers   Aspect,


What is difference between the TCP/IP and UDP socket

5 Answers   Invensys,


Categories