Base-Derived function over-riding confusion

I am reading the book Accelerated C++. Following is an excerpt from the book:
1
2
3
// Grad is a derived class of Core and regrade function is defined as follows
void Core::regrade(double d) { final = d; }
void Grad::regrade(double d1, double d2) { final = d1; thesis = d2; }


If r is a reference to a Core , then
1
2
r.regrade(100); // ok, call Core::regrade
r.regrade(100, 100); // compile error, Core::regrade takes a single argument 


(So far it is clear), However it goes on to say:

What may be more surprising is what happens if r is a reference to a Grad :


1
2
r.regrade(100);      // compile error, Grad::regrade takes two arguments
r.regrade(100, 100); //ok, call Grad::regrade 


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

I don't understand why the base class function gets hidden despite the fact that its signature is different. In fact the book itself goes on to say the following:

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


Am I getting confused between function overloading and overriding?
Topic archived. No new replies allowed.