Research the Rule of Dominance.
Wirthin a given scope, the local variable dominates a variable outside that scope.
[code]
int a = 10;
void AFunction()
{
int a = 5;
cout << a; //you see 5
}
The same is true with class methods. Whenever you have a derived class method, that method dominates. The donimation is based on the method
name only and not the arguments. Therefore, the derived class hides the base class method.
This is not good because your derrived objects can't use the base class method unless you code:
-
void Base::AMethod(int x)
-
{
-
-
}
-
void Derived::AMethod(int a, int b))
-
{
-
Base::AMethod(b); //recover base class logic
-
-
}
-
The problem is in whether the call to Base::AMethod is a pre-condition or a post-condition. That is, do you do it before or after the Derived class logic. Or both places? Now you have ambiguity and that spells poor design.
That means you cannot overload methods between classes. Inside the same class is OK but once you change scope, the dominance rule kicks in.
With an override (same method name and same arguments), you have exactly the same situation. But when you do this, it is presumed the override is done on a virtual method. This will correctly build the VTBL for the derived object. Otherwise, the derived method will still hide the base method and you lose base class functionality in the derived object.