Multi-justification for C + + overloading

Source: Internet
Author: User

Overloaded condition: The function parameter type and number are different, the return value is not considered. Cases:

void f (int  i); void F (double i);

One, float and double conditions:

void F (float  i); void F (double i);

If you enter a floating-point number, there is no justification, and void f (double i) is called because: in C + +, the floating-point numbers are converted to double types. If you enter: 10, there are many meanings, because the compiler does not know how to convert.
Ii. cases of Char and unsigned char

void Char c); void F (char c);

If the input: F (' C ') is not justified, but the input F (88) will produce a more semantic.
Three, the function uses the default parameter to produce the multi-meaning

void F ( in I,int j=1); void f (int i);

Entering F (20) will result in a lot of justification.

Multi-justification for C + + overloading

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: 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.