Interface implementation inheritance
A class inherits all interface implementations provided by its base classes. Without explicitly re-implementing an interface, a derived class cannot in any way alter the interface mappings it inherits from its base classes. For example, in the declarations interface IControl class Control: IControl class TextBox: Control the Paint method in TextBox hides the Paint method in Control, but it does not alter the mapping of Control.Paint onto IControl.Paint, and calls to Paint through class instances and interface instances will have the following effects Control c = new Control(); However, when an interface method is mapped onto a virtual method in a class, it is possible for derived classes to override the virtual method and alter the implementation of the interface. For example, rewriting the declarations above to interface IControl class Control: IControl class TextBox: Control the following effects will now be observed Control c = new Control(); Since explicit interface member implementations cannot be declared virtual, it is not possible to override an explicit interface member implementation. However, it is perfectly valid for an explicit interface member implementation to call another method, and that other method can be declared virtual to allow derived classes to override it. For example interface IControl class Control: IControl protected virtual void PaintControl() {...} class TextBox: Control Here, classes derived from Control can specialize the implementation of IControl.Paint by overriding the PaintControl method.
|