← Quiz: Type Casting in C++: all 10 questions
Quiz: Type Casting in C++ · Question 6 of 10
What is the legitimate use of constcast?
What is the legitimate use of const_cast?
- A.Modifying a variable declared const
- B.Converting int to double
- C.Passing const data to an old function that takes a non-const pointer but does not modify it
- D.Downcasting a base pointer
Answer & explanation
Correct answer: Passing const data to an old function that takes a non-const pointer but does not modify it
Removing const is fine only when nothing actually writes to the const object.
Can you get the rest right without peeking?
Take the timed Quiz: Type Casting in C++ quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →