The delicate part here is that virtual methods are a mechanism for sending a function call, and overloading is a function that affects call resolution.
That is, for any call, the compiler needs to figure out which method should be called (enable it); subsequently and in a logically different operation, it needs to generate code that calls the correct implementation of this method (send it).
From the above definitions of Base and Derived you can easily justify that if f(double) is called on Base* , then the call should be sent to any derived redefinition (if applicable) in the preference of the base implementation. But the answer to this question answers in a completely different way than
When the source tells pb->f(1.0) which of the methods named f should be used to resolve the method call?
As Sutter explains, the specification says that when the call is resolved, the compiler will look for methods named f declared on a static type pointed to by pb ; in this case, the static type is Base* , so the overloads (not overrides!) declared on Derived are not considered at all. However, if the method allowing the call is virtual , then the possible implementation provided by Derived will be used as expected.
Jon
source share