1. inherited rules
1. You can add new members to a derived class, but cannot remove inherited members;
2. constructor and destructor cannot be inherited. The access method of the members in the base class can only determine whether the derived classes can access them;
3. The new member defined in the derived class has the same name as the inherited member, but is overwritten, not removed;
4. classes can define virtual methods, virtual attributes, and virtual index indicators. The Derived classes are overloaded to achieve polymorphism;
5. A derived class can inherit only one base class, but multiple interfaces can be implemented.
2. Access Base members
1. Use base. Method Name ()
Base cannot be used in static methods
2. Explicit type conversion
3. Hide base class members
Public new void SayHello (){}
Iv. sealing and Methods
Sealed modifier. The modified classes and methods cannot be inherited or reloaded.
V. abstract classes and abstract methods
1. Use abstract Modification
2. abstract classes cannot be instantiated.
3. the abstract method does not execute specific code and must be rewritten in a non-Abstract derived class.
4. Methods in abstract classes are abstract methods.
5. If you want to override the implementation method in a non-abstract class but not in the base class, you need to use virtual functions (virtual)
Vi. Multi-Inheritance
To implement methods with the same names for multiple interfaces, note the following two points:
1. keywords such as public cannot be added before methods with the same name. The corresponding interface name must be added before each method;
2. A method without a name must be preceded by a "public" identifier
Public void Hello (){}
When creating an instance of a derived class, if you call the implementation of an interface, you must forcibly convert the instance to the corresponding interface type.
VII. Inheritance and access modifier
By: dxh_0829