GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  HCL
Go To First  |  Previous Question  |  Next Question 
 HCL  |  Question 8 of 23    Print  
what is RTTI in c++?

  
Total Answers and Comments: 2 Last Update: April 21, 2006     Asked by: dimpy 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Amit Mishra
 
RTTI is a compiler was developed by microsoft with the help of visual C which work is, if we don't declared datatype to particular variable, then this compiler take defaultly the datatype of the variable according to the data defined to it. E.g. if we write only#include "stdio.h"void main() { x=5; y=6.9; z= 'A'; . . .. }Then compiler takes defaultly x as integer, y is float & z is char types.

Above answer was rated as good by the following members:
sundarshi
March 21, 2006 14:16:32   #1  
Amit Mishra        

RE: what is RTTI in c++?
RTTI is a compiler was developed by microsoft with the help of visual C which work is if we don't declared datatype to particular variable then this compiler take defaultly the datatype of the variable according to the data defined to it. E.g. if we write only#include stdio.h void main() { x 5; y 6.9; z 'A'; . . .. }Then compiler takes defaultly x as integer y is float & z is char types.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
April 20, 2006 15:51:53   #2  
mohit12379 Member Since: March 2006   Contribution: 17    

RE: what is RTTI in c++?

Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries were implementing this functionality themselves. This caused incompatibilities between libraries. Thus it became obvious that support for run-time type information was needed at the language level.

There are three main C++ language elements to run-time type information:

1)The dynamic_cast operator. :- Used for conversion of polymorphic types.

class B { ... };
class C : public B { ... };
class D : public C { ... };

void f(D* pd)
{
C* pc dynamic_cast<C*>(pd);// ok: C is a direct base class
// pc points to C subobject of pd

B* pb dynamic_cast<B*>(pd);// ok: B is an indirect base class
// pb points to B subobject of pd
...
}
---------------------------------------------------------------------------

2)The typeid operator :- Used for identifying the exact type of an object.

3)The type_info class :- Used to hold the type information returned by the typeid operator.The type_info class describes type information generated within the program by the compiler.

NOTE:- TRY THIS EXAMPLE IS COMPILE AND LINK USING MSVC++ 6.0 CL.EXE Compiler and Linker PLS CHECK SAME typid available in UNIX based C++;
**************************************************************************************
#include stdio.h
#include <typeinfo.h>

class A
{
public:
};

class B:public A
{
public:
};

int main(int argc char* argv[])
{
int iVal int();
float fVal float();
char cVal char();
A a a1;
B b;

const type_info& t_iVal typeid(iVal); // Holds Simple int DataType Info
const type_info& t_iValRef typeid(&iVal); // Holds pointer type_info
printf( \n Type Info of iVal s\n t_iVal.name());
printf( \n Type Info of &iVal s\n t_iValRef.name());

printf( \n Type Info of fVal s\n typeid(fVal).name());
printf( \n Type Info of &fVal s\n typeid(&fVal).name());

printf( \n Type Info of cVal s\n typeid(cVal).name());
printf( \n Type Info of &cVal s\n\n typeid(&cVal).name());

printf( \n Type Info of a s\n typeid(a).name());
printf( \n Type Info of b s\n\n typeid(b).name());

if(typeid(a) typeid(a1))
{
printf( \n BOTH INSTANCES a AND a1 BELONGS TO SAME CLASS \n\n );
}

return 0;
}
*****************************************************************************************


HI ANY QUERIES OR EVEN ANY GOOD IDEA LIKE TO SHARE WITH ME PLS WRITE ME at mohit.gonduley@gmail.com


 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. RTTI was added to the C++ language because many vendors of class libraries were implementing this functionality themselves. This ...
Read Answers (2) | Asked by : dimpy


 Sponsored Links

 
Related Articles

Verizon Interview Procedure and Placement Paper

Please find the Verizon Interview Procedure and Placement Paper from May 2005.http://www.geekinterview.com/question_details/13365
 

Polaris Interview Preparation and Model Question papers

Polaris Interview Preparation and Model Question papers :  Please find Aptitude(41), Analytical(28), Interview Procedure(1)Click here to view the section
 

Nucleus Interview Preparation and Model Question papers

Nucleus Interview Preparation and Model Question papers. The following model question papers are added. Up One Level   Global-Interview-Questions » Nucleus »
 

Oracle Interview Preparation and Model Question papers

Oracle Interview Preparation and Model Question papers updated with more SQL Questions, Technical, RDBMS Basics and C. Oracle  
 

Mascot Interview Procedure, Pattern and Model Question Papers

Mascot Interview Procedure, Pattern and Model Question Papers Interview ProcedureAt the moment we do not have much informaton about the interview though the candidate may be required to go through both technical and HR interviews. There are a total 6 sections in the written test. Each section h
 

Ramco Interview Procedure, Pattern and Model Question Papers

Ramco Interview Procedure, Pattern and Model Question Papers section added.Interview ProcedureThe information on the interview is pretty sketchy but it consists of both technical grilling and HR interview.The written test consists of both aptitude and a technical test.The aptitude section of the tes
 

Keane India Placement Paper

Hi all , I recently went for Keane India Testing Paper. They offer 2 courses. 1. Advanced Application Programming 5 months course roughly 2. Testing Course 45 days roughly Selected students are given trainig and then the one efficient in their work are absorbed by Keane as Trainee on Stipend b
 

A couple of papers by Mladen Gogala

I was looking for something on google groups last night and came across a post by Mladen that included a link to his website. As I did not remember him having a site I went for a look. Mladen's site....[Read More] Posted by Pete On 03/10/05 At 10:36 PM
 

Will Paying for Resume Placement on Job Boards Help Your Search?

More job hunters are ponying up in hopes of a better chance of getting noticed by employers. But is it worth the money?
 

Justin talks about a new series of papers on Oracle security by Arup

I saw Justin's post today to his blog titled " Default Passwords are Evil " and could not agree more. The latest Oracle worm takes advantage of the fact that Oracle has so many default users with known default passwords....[Read More] Posted by Pete On 09/01/06 At 09:55 PM
 

Related Categories
Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape