Question 13
Back to Exercise
A Base* points to a Derived object that overrides virtual f(). Which f() does p->f() call?
- A Base::f(), because p is a Base*
- B Derived::f(), chosen at run time from the actual object type Correct
- C Both
- D It does not compile
Correct Answer: Option B
That is dynamic binding. Without virtual, the call would be resolved at compile time from the pointer type and call Base::f().
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!