And that's kinda why overriding (and in general, any virtual members) is something that should be done very carefully...
In fact, generally, when overriding, you should try to code both the base class and the derived class, so that the derived class implementation first calls the base implementation, and then executes it's additional functionality...
but this principle is not enforced in OO languages, and is often violated...
Example of why this is bad
Imagine you have CompanyA designs Type ( class ) Phone
namespace CompanyA {
class Phone {
public void Dial() {
// do work to dial the phone here
}
}
}
No iagine Company B defines another type BetterPhone, that uses Company A's Phone as base type...
namespace CompanyB {
class BetterPhone: CompanyA.Phone {
public void Dial() {
Console.WriteLine("BetterPhoneDial");
EstablishConenction();
base.Dial();
}
}
}
Now CompanyA, whose Phone class is in use by other Companies (Company C, D, etc.) decides that establishing a connection is a useful thing to have in the class, and modifies CompanyA.Phone, adding an EsatblishCOnnection() method as well, perhaps with a different implementation... Until we had the "new" keyword, this scenario would have broken CompanyB's BetterPhone class... the first time they attempted to use the new base class.