|
|
|
|
What may be more surprising is what happens if r is a reference to a Grad : |
|
|
Now when we look for a function to call, r is a Grad . The regrade function that applies to Grad objects takes two arguments. Even though there is a base-class version that takes a single argument, that version is effectively hidden by the existence of regrade in the derived class. If we want to run the version from the base class, we must call it explicitly: |
r.Core::regrade(100); // ok, call Core::regrade
Overriding: A derived-class member function overrides a function with the same name in the base class if the two functions have the same number and types of parameters and both (or neither) are const. In that case, the return types must also match, except that as in ยง13.4.2/246, if the base-class function returns a pointer (or reference) to a class, the derived-class function can return a pointer (or reference) to a derived class. If the argument lists don't match, the base- and derived-class functions are effectively unrelated |