Meaning of a virtual member function
Question
Explain what a virtual function is in C++.
Short answer
A member function whose call is resolved by the object's run-time type. Calling it through a base pointer or reference executes the most-derived override, which is how C++ gives run-time polymorphism. A pure virtual function (= 0) has no base implementation and makes the class abstract.
Adapted from Joshi, Denson & Downes, Quant Job Interview Questions and Answers, Q7.10, p.226; question and answer rewritten by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solution