如何使用overload

如何使用overload Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061204165744296.html
我在unit1中定义了一个涵数funciton   xxx(cc):double,我想在unti5中重载,请问在unit5中该怎样用呢?还有就是在unit1中是否需在涵数funciton   xxx(cc):double后加上overload?请大家多多帮忙,谢谢?

同一个单元才用overload,多个单元互不相关

那么在同一个单元中又该怎样用呢?  
  是不是:funciton   xxx(cc:integer):double;overload;//已经声名过的.  
  funciton   xxx(cc:double):double;overload;//需要重载的.

观注...

只有一个   不用写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;  
 

摘录DELPHI   HELP   解释得很清楚了  
   
  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;

overload的用法已经有人解释的很清楚了  
  如果在同一个类中,有两个函数或过程,他们的功能很相似,但是需要传入的参数值不同,可以考虑用overload实现,这样在调用的时候,系统会根据传入的参数表自动判断需要调用的是哪个函数。

转载于:https://www.cnblogs.com/delphi2007/archive/2009/04/22/1441143.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值