Section 7, cover the virtual interface
Sometimes we need to express an abstract thing, it is a summary of something, but we can't really see that it has become an entity in front of us, and has an abstract class for this object-oriented programming language. C # As an object-oriented language, it will inevitably introduce an abstract class. Interfaces and abstract classes allow you to create a definition of component interactions. Through the interface, you can specify the method you must implement, but do not actually specify how to implement the method. Abstract classes allow you to create behavior definitions and provide some public implementations for inherited classes. Tools that implement polymorphisms, interfaces, and abstract classes in components.
An abstract class must provide all members of the interface listed in the basic class list. However, an abstract class is allowed to map the interface method into the abstraction method. E.g
Interface iMethods {
Void f ();
Void g ();
}
Abstract Class C: iMethods
{
Public abstract void f ();
Public Abstract Void g ();
}
Here, iMethods's implementation function maps F and G to the abstract method, they must be overwritten in non-abstract classes from C.
Note that the explicit interface member implementation function cannot be abstract, but the explicit interface member implementation function can of course call the abstraction method. E.g
Interface iMethods
{
Void f ();
Void g ();
}
Abstract Class C: iMethods
{
Void iMethods.f () {ff ();
Void iMethods.g () {gg ();
Protected abstract void ff ();
Protected abstract void gg ();
}
Here, the non-abstract class derived from C is to cover the FF and GG, so an actual implementation of IMETHODS is provided.