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

Program to check whether a word is the first word of the sentence.

1 Answers  


Who invented oop?

0 Answers  


explain sub-type and sub class? atleast u have differ it into 4 points?

0 Answers   Infosys,


which structured data type is not used in c++? 1.union 2.structure 3.string 4.boolean

2 Answers   HCL, Wipro,


What are the 3 pillars of oop?

0 Answers  






Which type does string inherit from?

0 Answers  


What is a class and object?

0 Answers  


What is an advantage of polymorphism?

0 Answers  


which is platform independent device used in computers

2 Answers  


write a program to find 2^n+1 ?

0 Answers   CTS,


What is a class?

32 Answers   Infosys, TCS, Thylak,


Write a program to get the binary tree.

3 Answers   ABC,


Categories