Study Notes: C # View "object" from "process"-class and basic implementation

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.