3, re-implement the interface
We have already introduced that derived classes can overload the membership methods that have been defined in the base class. Similar concepts are introduced into the implementation of the class to the interface of the interface (RE-Implement). The class that inherits the interface implemented can be rectified. This interface requires that occurs in the list of class definitions. The reality of the interface must also strictly comply with the rules of the first implementation interface, and the derived interface mapping does not have any impact on interface mappings established for the empowerment of the interface.
The following code gives examples of interface reality:
Interface icontrol {void point (); class control: icontrol void icontrol.paint () {...} Class MyControl: Control, Icontrol public void Paint ()}}
In fact,: Control maps icontrol.paint to Control.icontrol.Paint, but this does not affect the reality in MyControl. In the rectification in MyControl, iControl.Paint is mapped to MyControl.Paint.
When the reality of the interface, the inherited public member definition and the definition of the explicit interface member of the explicit interface is involved in the process of interface mapping.
Using system; interface iMethods {void f (); void g (); void h (); void i ();} class base: iMethods {void iMethods.f () {} void iMethods.g () {} public void H () {} public void i () {}} class derived: base, iMethods {public void f () {} void iMethods.h () {}}
Here, the implementation of the interface IMETHODS in Derived maps the interface method to derived.f, base.imethods.g, derived.imethods.h, and base.i. As we said, the class is implicitly implemented all the parent interfaces of the interface when implementing an interface. Similarly, the class is implicitly reached all parent interfaces of the interface while re-implementing an interface.
Using system; interface ibase {void f ();} interface idherid: ibase {void g ();} class c: idherived {void ibase.f () {// The code implemented to F ...} void iderived.g ( ) {// implement code ...}} class d: c, iDerived {public void f () {// Implemented code ...} public void g () {// Implemented the code ...}}
Here, the reality of iDerived also implements the reality of IBase, and maps IBASE.f to D.f.