C++/C Function Properties

Source: Internet
Author: User

1. Compared to the C function, C + + adds overloads, inline, const (for member functions only), and virtual (member function only) mechanisms.

2. Overloaded functions can be distinguished only by argument lists and not by return values.

3. Global functions and class member functions have the same name and cannot be overloaded with different scopes.

4. member function overloading conditions:

(1) Have the same scope (in the same class).

(2) The function has the same name.

(3) different parameter types, order, or number (including const and non-const parameters).

(4) The virtual keyword is optional.

5. The member function overrides the condition:

(1) There are different scopes (in base classes and derived classes).

(2) The function has the same name.

(3) The parameter list is the same.

(4) A base class function is a virtual function.

6. The member function hides the condition:

(1) The derived class and the base class have the same name, but the argument list is not the same, regardless of whether the base class has the virtual keyword, the function of the base class is hidden in the derived class.

(2) The derived class and the base class have the same name, the parameter list is the same, the base class has no virtual keyword, and the function of the base class is hidden in the derived class.

7. Remove the member function from the hide, use the Using keyword, such as using Base::functon;

C++/C Function Properties

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.