How to Use overload

Source: Internet
Author: User
How to Use overload Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiBase/html/delphi_20061204165744296.html
In unit1, I defined an Han number funciton XXX (CC): double. I Want To reload it in unti5. How can I use it in unit5? In unit1, do I need to add overload after the Han number funciton XXX (CC): double? Thank you for your help?

Overload is used for the same unit. Multiple Units are irrelevant.

So how should we use it in the same unit?
Is it: funciton XXX (CC: integer): Double; overload; // well known.
Funciton XXX (CC: Double): Double; overload; // the value to be overloaded.

View note...

Only one node does not need to write overload.

Function micun_getchecksum (const c_src: ansistring; const c_bits: byte = 32): longword; overload;
Function micun_getchecksum (const c_src: widestring; const c_bits: byte = 32): longword; overload;

The excerpt from Delphi help gives a clear explanation.

You can declare more than one routine in the same scope with the same name. this is called overloading. overloaded routines must be declared with the overload directive and must have distinguishing parameter lists. for example, consider the declarations

Function divide (X, Y: Real): real; overload;
Begin
Result: = x/y;
End;
Function divide (X, Y: integer): integer; overload;
Begin
Result: = x Div y;
End;

The usage of overload has been clearly explained.
If there are two functions or procedures in the same class, their functions are very similar, but the input parameter values are different, you can consider using overload implementation, so that when calling, the system automatically determines which function to call based on the input parameter table.

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.