If a virtual member function
vf is declared in a class
Base and in a class
Derived, derived directly or
indirectly from
Base, a member function
vf with the same
name, parameter-type-list (
[dcl.fct]), cv-qualification, and ref-qualifier
(or absence of same) as
Base::vf is declared,
then
Derived::vf overrides
Base::vf. For convenience we say that any virtual function
overrides itself
. A virtual member function
C::vf of a class object
S is a
final
overrider unless the most derived class (
[intro.object]) of which
S is a
base class subobject (if any) declares or inherits another member function that overrides
vf. In a derived class, if a virtual member function of a base class subobject
has more than one final overrider the program is ill-formed
. [
Example 1:
struct A {
virtual void f();
};
struct B : virtual A {
virtual void f();
};
struct C : B , virtual A {
using A::f;
};
void foo() {
C c;
c.f();
c.C::f();
}
—
end example]