different types of castings

Answers were Sorted based on User's Feedback



different types of castings..

Answer / mms zubeir

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 ?    6 Yes 4 No

different types of castings..

Answer / sanjay makwana

Const Cast,
Static cast,
reinterprit cast,
dynamic cast

Is This Answer Correct ?    8 Yes 7 No

different types of castings..

Answer / vinayaka kc

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 ?    5 Yes 4 No

Post New Answer

More OOPS Interview Questions

How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

0 Answers  


What is oops and why we use oops?

0 Answers  


explain defference between structure and class with example

1 Answers  


design class for linked list and include constructor,destructor,insert option. struct node { int node; struct node &ptr; }

1 Answers   HSBC,


write a program which best describes polymorphism in real world?

2 Answers   CTS, Infosys, NexGen,






what is virtual destructor

7 Answers   L&T, TCS,


What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass

6 Answers   Wipro,


features of OOPS

22 Answers   Ness Technologies, Satyam,


Why is abstraction needed?

0 Answers  


What is DeadlyDiamondDeathProblem ?

1 Answers  


Which is not an object oriented programming language?

0 Answers  


Please tell me the oops concept with detailed answer

9 Answers   EEE,


Categories