Question 4
Back to Exercise
Derived d; calls d.f() where f is virtual. How is the call resolved?
- A Through the vtable
- B Statically – the object's type is known exactly, so no dynamic dispatch is needed Correct
- C It calls Base::f
- D Undefined behaviour
Correct Answer: Option B
Dynamic dispatch matters only for calls through pointers or references, where the dynamic type may differ from the static type.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!