Differences between parent-child classes, member function overrides, overloads, and redefinition

Source: Internet
Author: User

1. overridingOverride: Also known as overwrite. subclasses redefine virtual functions in the parent class that have the same name and argument list. function features are the same.

Overrides need to be noted:

1) The overridden function cannot be static.it has to be virtual.2) The overriding function must have the same type, name, and parameter list 3) the access modifiers of the overridden function can be different. Although virtual is private, overriding in a derived class can be rewritten as public,protected 2. Heavy Duty Overload: The function name is the same, the parameter list and other characteristics are different. But it cannot be judged by the return type. 3.Redefine redefiningAlso called hiding:

Subclasses redefine non-virtual functions with the same name in the parent class (the argument list can be different).

in summary, summarized as follows: 1 Overloaded Features:
A the same range (in the same class)
The b function has the same name c parameter is different d virtual keyword is optional 2 override (overwrite) refers to a derived class function that overrides a base class function, characterized by: a different range, located in the base class and the derived class, respectively The name of the B function is the same same as C parameterThe D base class function must have the virtual keyword 3 redefinition (hidden) refers to a function of a derived class that masks a base class function with the same name as the following rule: a If the function of the derived class and the function of the base class have the same name, but the arguments are different, at this point, the function of the base class is hidden, regardless of whether or not virtual. b If the function of the derived class has the same name as the function of the base class, and the parameters are the same, but the base class function does not have the Vitual keyword, the function of the base class is hidden.

Differences between parent-child classes, member function overrides, overloads, and redefinition

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.