Function overloading/declare function, overloadingdeclare

Source: Internet
Author: User

Function overloading/declare function, overloadingdeclare

  • Declare a function

To declare a function without identifying the argument list, you can do it in this way:

Void say hello (...);

Here, you use three point (...) to indicate that the function have no argument.

 

  • Function overloading

Keep in mind that the signature, not the function type, enables function overloading. For example, the following two declaration are incompatible:

Long gronk (int n, float m); #1 // same signature

Double gronk (int n, float m); #2 // hence not allowed

Why, for example, if this is possible:

Int El = 0;

Float haa = 3;

Gronk (El, haa); // which function to use, #1 or #2, it is conflict.

Therefore, C ++ doesn't allow you to overload gronk () in this fashion. You can have different return type, but only if the signature are also different, for example:

Long gronk (int n, float m );

Double gronk (double n, double m); // now it is allowed

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.