Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

different types of castings

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1233


How do you achieve polymorphism?

259


Whats is abstraction in oops?

235


What is static in oop?

246


Is html an oop?

260






Can abstract class have normal methods?

245


What is constructor in oop?

228


Why do we use class in oops?

237


write a C++ program for booking using constructor and destructor.

1708


How long to learn object oriented programming?

248


write a program that takes input in digits and display the result in words from 1 to 1000

1624


What are the benefits of polymorphism?

254


what is the drawback of classical methods in oops?

2547


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

776


What is data binding in oops?

243