Knocking on the door of C #-inheritance,

Source: Internet
Author: User

Knocking on the door of C #-inheritance,

Record some concepts for memo.

 

Second in life, second in life, and third in life. Class generation, endless growth.

The difference between rewriting and overloading:

Overload refers to the method with the same name but different parameters in the same class.

Override refers to the method inherited by the base class in the derived class in the inheritance relationship. In this case, the base class and the derived class have two methods with the same name.

The execution process of the constructor In the derived class:

First, the base class constructor is called to initialize the variables of the derived class, which is a process of gradually building from the base class to the derived class. When deleting an object, first call the destructor of the derived class, destroy the variables of the derived class, then call the function of the base class, and destroy the variables of the derived class. This process is like wearing clothes. When wearing clothes, first wear the innermost layer of the clothes, and then wear the outer layer of the clothes; when taking off the clothes, first take off the outer layer of the clothes, and then take off the inner layer of the clothes.

 

Related Article

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.