"Vajira" <va*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello,
Thank for your replys. I have gone though the sites. It clearly
describes how C++ compilar handles this problem.
But still I coun't find why C++ compilar hinding overloaded member
function of base class.
1. Is there any advantage by hinding these functions ?
2. What is the logical reason for this ?
Sorry for bothering you guys, but I still curious of this matter.
Thank you......
You wrote a virtual function in the base class. If you want your derived
class to modify what that function does, then you need to override it in the
derived class. And to properly override the function, it has to have the
same parameter list as the base class version. If it does not, then the
function in the derived class will "hide" the function of the same name in
the base class. That's just the rules.
You might ask yourself why you have two functions with the same name in your
base and derived classes, but with different parameter lists. The fact that
you made the base class function virtual implies that you wanted to override
it (or at least allow it to be overridden). But then you wrote a derived
class function that does *not* override it, because it's truly a different
function (as shown by its different parameter list).
So, what exactly do you want to do: override the function, or call a
different function? If the answer is "override it", then use identical
paremeter lists. And if the answer is "call a different function", then see
that previously stated FAQ for ways to accomplish that, or else just rename
the function in your derived class.
-Howard
(P.S., as to "why" something was done, that's not usually discussed here,
and isn't really important to getting the job done, right?)