*Run Time Type Identification
*enables us to identify type an object during execution of program
*RTTI operators are runtime events for polymorphic classes and compile time events for all other types.
* two type of RTTI operators are:
1. typeid
2. dynamic_cast
typeid
*typeid is an operator which returns refrence to object of type_info class
*Type_info class describers type of object
#include<type_info.h>
main()
{
int i,j;
float f;
char* p;
A a;
B b;
cout<<"type of i is "<<typeid(i).name();//int
cout<<"type of f is "<<typeid(i).name(); //float
cout<<"type of p is "<<typeid(i).name(); //char*
cout<<"type of a is "<<typeid(i).name();//class A
cout<<"type of b is "<<typeid(i).name(); //class B
}
casting operators
*dynamic_cast
*static_cast
*cont_cast
*reinterpret_cast
syntax:
cast_name<type>(expression)
*enables us to identify type an object during execution of program
*RTTI operators are runtime events for polymorphic classes and compile time events for all other types.
* two type of RTTI operators are:
1. typeid
2. dynamic_cast
typeid
*typeid is an operator which returns refrence to object of type_info class
*Type_info class describers type of object
#include<type_info.h>
main()
{
int i,j;
float f;
char* p;
A a;
B b;
cout<<"type of i is "<<typeid(i).name();//int
cout<<"type of f is "<<typeid(i).name(); //float
cout<<"type of p is "<<typeid(i).name(); //char*
cout<<"type of a is "<<typeid(i).name();//class A
cout<<"type of b is "<<typeid(i).name(); //class B
}
casting operators
*dynamic_cast
*static_cast
*cont_cast
*reinterpret_cast
syntax:
cast_name<type>(expression)