LearnFrenzy
Sign in Take a free test

Polymorphism and Virtual Functions · Polymorphism MCQ · Question 4

Is a call on an object by name dynamically dispatched? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links