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 long to learn object oriented programming?

0 Answers  


officer say me - i am offered to a smoking , then what can you say

0 Answers  


Why do we use oop?

0 Answers  


What is extreme programming?

2 Answers  


What is the important feature of inheritance?

0 Answers   BPL,






why constructor cannt be declar virtually? why destructor cannt be overloaded?

2 Answers   Infosys,


what is the main difference between sizeof() operator in c and c++

3 Answers  


what isthe difference between c structure and c++ class

5 Answers  


How can i write a code in c# to take a number from the user and then find all the prime numbers till the number entered by the user.

4 Answers   NIIT, TCS,


What are the four main oops concepts?

1 Answers  


tell about copy constructor

3 Answers   Siemens,


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }

1 Answers  


Categories