← Quiz: Type Casting in C++: all 10 questions
Quiz: Type Casting in C++ · Question 7 of 10
Why are C-style casts like (int)x discouraged in C++?
Why are C-style casts like (int)x discouraged in C++?
- A.They do not compile in C++
- B.They are slower at run time
- C.They can perform any kind of conversion silently and are hard to search for
- D.They always round instead of truncating
Answer & explanation
Correct answer: They can perform any kind of conversion silently and are hard to search for
The named casts make intent clear and let the compiler reject the wrong kind of conversion.
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 →