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                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
different types of castings
 Question Submitted By :: Palnati
I also faced this Question!!     Rank Answer Posted By  
 
  Re: different types of castings
Answer
# 1
Const Cast,
Static cast,
reinterprit cast,
dynamic cast
 
Is This Answer Correct ?    0 Yes 0 No
Sanjay Makwana
 
  Re: different types of castings
Answer
# 2
2 types of casting 
1] Implicit casting
2] Explicit casting
   (a)Const Cast,
   (b)Static cast,
   (c)reinterprit cast,
   (d)dynamic cast;
 
Is This Answer Correct ?    0 Yes 0 No
Vinayaka Kc
 
 
 
  Re: different types of castings
Answer
# 3
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.
 
Is This Answer Correct ?    0 Yes 0 No
Mms Zubeir
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
What is command routing in MFC GE1
Write a macro for swapping integers  3
what is the virtual function overhead, and what is it used for ? i hope i can get and appropriate answers, thanks a lot....  5
Difference between over loading and over ridding? CTS10
Which is faster post increment or pre increment ? and in which cases should u use either - to increase speed? EA-Electronic-Arts2
swapping program does not use third variable  4
What is the difference between declaration and definition?  6
What do you mean by pure virtual functions?  4
We have a scale and 7 balls. 1 ball is heavier than all the rest. How to determine the heaviest ball with only 3 possible weighing attempts? IBM3
//what is wrong with the programme?? #include<iostream.h> template <class first> class dd { first i; public: void set(); void print(); }; void dd< first>:: set() { cin>>i; } void dd< first>::print() { cout<<"\n"<<i; } void main() { dd <char>g; g.set(); g.print(); }  1
You have one base class virtual function how will call that function from derived class?  4
to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 123  1
What is public, protected, private? Satyam4
When is an object created and what is its lifetime? IBM1
What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; } 1) The computer will output "0123...99" 2) The computer will output "0123...100" 3) The output is undefined  3
Definition of Object Oriented Programming in single line? TCS14
what is new modifier in C# HCL6
tell about copy constructor Siemens1
what is meant by files? Infosys2
What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile  3
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
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