ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories >> Software >> Programming-Languages >> C++ >> OOPS
 
 
 
Question
different types of castings
 Question Submitted By :: Palnati
I also faced this Question!!     Rank Answer Posted By  
 
Answer
The above answers are correct. I would like to add some 
details to those.

1. const_cast:- is used to cast away the constness of a 
variable.

2. static_cast:- is used to cast between two types with the 
available static information about the variable. It doesn't 
know anything about the run time information. Additionally, 
it knows the type and access previledges of the 
variables/objects involved in the casting. For example, we 
cannot cast a private base.

3. reinterpret_cast:- is used to cast between any pointer 
types and the types need not be related. The developer 
needs to take care of the correct types to be casted.

4. dynamic_cast:- is used to cast between polymorphic types 
only. It allows downcasting and casting between siblings as 
well. If the cast fails, it returns a 0/NULL instead of the 
pointer to the resultant object incase of success.
 
3
Mms Zubeir
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com