Follow Our FB Page << >> 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

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 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.


How do you achieve polymorphism?


Whats is abstraction in oops?


What is static in oop?


Is html an oop?


Can abstract class have normal methods?


What is constructor in oop?


Why do we use class in oops?


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


How long to learn object oriented programming?


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


What are the benefits of polymorphism?


what is the drawback of classical methods in oops?


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


What is data binding in oops?