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

How to update all the views whenver document got updated ?

1 Answers  


What MFC base classes provide support for ActiveX controls?

2 Answers   Wipro,


What is the initial function to be called in MFC and what it will do

11 Answers   Infosys,


1)dynamic creation of a Button ?

2 Answers   TCS,


What is mfc class hierarchy?

0 Answers  






1) create ToolTip in MFC?

2 Answers   HCL,


if both base and derived class have the constructors if i create an object for derive class which class constructor is executed first

10 Answers   Siemens, Symphony,


how can u change button shape at run time

3 Answers   Samsung,


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  


I can i set size of integer variable should be fixed for different operating systems(Ex i want integer size is 2bytes in OS)

2 Answers   Invensys,


What is CALLBACK? How it work? what is the advantage of CALLBACK, please explain with an example

6 Answers  


Explain about MDI and CMultiDocTemplate ?

2 Answers  


Categories