This is to do with
names not the functions themselves.
names in C++ are the identifiers given to variables, classes, functions, etc..
names in c++ are scoped.
you can have several overloaded functions in a scope with the same name - but as far as
names is concerned the name is only used
once.
This is the whole concept between
scopes and
names and
name hiding.
Remember back to basic exercises when you learn about scopes - you probably saw/did something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
//some_file.cpp
int x; //name x at global scope
int main()
{
int x; // name x used again but this time in function main() scope
x = 3; //uses x from main() scope
{ //introduce an inner sope
int x; //use the name x again
x = 6; //uses the x from this scope
::x =9; //uses x from the global scope
}
}
|
I'm sure you understod that.
So coming back to your original problem;
You have the Derived class scope (Derived::), surrounded by the Base class scope (Base::)
surrounded by the Global scope (::).
So the fact that you have re-introduced the name
mf1 into the Derived class scope
hides the same name from the Base class scope.
So in Derived class you only have one function called mf1.
Note that inheritance is still happening - just that names are hidden.
As you have noticed - you can use
Base:: scope resolution to use the hidden functions.