Class implementationProcess:
1. Define struct (the base type field is the value type, the reference type field and method are pointers.Note:Attribute is essentially a combination of fields and methods ).
2. Define a function (the first parameter is of the struct type, which is automatically filled in by the compiler during calling, followed by the "actual" parameter of the function ).
Class instantiationProcess:
1. allocate memory space andInitialize fields and attributes. UsageNew
Keyword.
2. Call the constructor. Of course, in general, constructors are used to assign initial values to fields and attributes.
Inheritance implementation:
Principle:Define a struct pointer pointing to the parent class in the struct that implements the subclass.
Overwrite: Overwrite the parent method. C # implementation is to define a method in the subclass, which is the same as the method declaration of the parent class, or addNewKeyword.
This is actually to tell the compiler-when a "function" is called, if the first parameter is declared as the parent class (actually the instantiated subclass), the parent class will be executed.
Method, but also the subclass method.
Rewrite:C # The implementation is that the parent class method uses
VirtualKeyword declaration, subclassOverrideKeyword declaration. The actual function is to tell the compiler whether it is
In which case, the method of the first parameter is used directly.
Here, we have to say that covering and rewriting are all taken into account on the Internet. As far as I can see, coverage is like an apprentice learning martial arts with the master.
"Taishan pressure top", maybe the master directly squashed his face and beat it down, and the apprentice jumped three thousand feet, and then came up at the bottom of his head, although it was also called Taishan pressure top, but it was real
In the meantime, we have achieved the same effect. This is the coverage. The apprentice has, and the apprentice's master will, but it is different. The rewriting is like the father's passing on the Shimei Yu thing.
Son, the son has carved this fine-grained Jade into exquisite ornaments, so the family has a treasure, but the son's father has gone. (Note: apprentice and son
It is like a child-class entity. The master of this apprentice and the father of this son are like the parent class instantiated by the Child-class. The method is like the method of Taishan Summit and Shishi Meiyu)
Subclass instantiation:
Instantiate the parent class before instantiating the Child class.Note:The first task is to instantiate the object class.