← Quiz: Type Casting in C++: all 10 questions
Quiz: Type Casting in C++ · Question 3 of 10
What does dynamiccast<Manager (p) return if p points to an Engineer object (not a Manager)?
What does dynamic_cast<Manager *>(p) return if p points to an Engineer object (not a Manager)?
- A.A Manager pointer with random data
- B.It throws std::bad_cast
- C.nullptr
- D.A compile error
Answer & explanation
Correct answer: nullptr
For pointers, a failed dynamic_cast returns nullptr; for references it throws bad_cast.
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 →