Comparison between override and overload

Source: Internet
Author: User

In fact, the essential difference is to look at function features: the features of the two override functions are the same, while the names of the two overload functions are the same, function features are different.
Function features include the function name, parameter type, and number.
Override is inherited. If the function you write is the same as the feature of the function to be inherited, add this keyword, when this function of this subclass is used, the function of the parent class (or superclass) is invisible and overwritten.
For example, derived inherits the base, which contains void a (int)
If you think that A is not well written or suitable for this class in derived, you want to re-writeCodeThen override void a (int A) is written, and the original function is overwritten by the new one.
Overload is a heavy load, that is, the function name is the same, and the function features are different, the system will adjust the corresponding function according to the parameters you provide.
For example: void a (int A) and void a (int A, int B)
If you use a (1), the first one is called. If it is a (), the second one is called.

[Name: override and overload] [tags:. Net]

[From alphawu. Blog]

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.