different types of castings
Answers were Sorted based on User's Feedback
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 |
Answer / sanjay makwana
Const Cast,
Static cast,
reinterprit cast,
dynamic cast
| Is This Answer Correct ? | 8 Yes | 7 No |
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 |
What is the real time example of inheritance?
what is graphics
what do you mean by static member variable?
Why is there no multiple inheritance?
Hi All, I am new to programming and want to know how can i write a code to take input of 2 numbers from user and swap it without using a temp variable?
What is overloading and its types?
Why do we use oop?
What are generic functions and generic classes?
how to swap the variables without using temp and operators
What are the important components of cohesion?
There are 2 empty jars of 5 and 3 liters capacity. And a river is flowing besides. I want to measure 4 liters of wanter using these 2 jars. How do you do this?
when my application exe is running nad i don't want to create another exe what should i do