The difference between overloading, overwriting, hiding

Source: Internet
Author: User

1 characteristics of member functions being overloaded
(1) The same range (in the same class);
(2) The function has the same name;
(3) different parameters;
(4) The virtual keyword is optional.
2 "Overwrite" means that the derived class function overrides the base class function, which is characterized by:
(1) different ranges (in the derived and base classes, respectively);
(2) The function has the same name;
(3) the same parameters;
(4) The base class function must have the virtual keyword.
3 "hidden" refers to a function of a derived class that masks a base class function with the same name, characterized by:

(1) different range (in the derived class and the base Class), (2) The function name is the same, (3) The parameters can be different; (4) The base class function has no virtual keyword

Summary: the base class is the same as the function name in the derived class, the base class function has the virtual keyword and the function parameter is the same, it belongs to the overwrite; there is no virtual keyword in the base class, which belongs to the hidden

The difference between overloading, overwriting, hiding

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.