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.