delphi 重载 重写_Delphi方法重载和默认参数

delphi 重载 重写

Functions and procedures are an important part of the Delphi language. Starting with Delphi 4, Delphi allows us to work with functions and procedures that support default parameters (making the parameters optional), and permits two or more routines to have an identical name but operate as completely different routines.

函数和过程是Delphi语言的重要组成部分。 从Delphi 4开始,Delphi允许我们使用支持默认参数的函数和过程(使参数成为可选参数),并允许两个或多个例程具有相同的名称,但作为完全不同的例程进行操作。

Let's see how Overloading and default parameters can help you code better.

让我们看看重载和默认参数如何帮助您更好地编码。

超载 ( Overloading )

Simply put, overloading is declaring more than one routine with the same name. Overloading allows us to have multiple routines that share the same name, but with a different number of parameters and types.

简而言之,重载声明了多个同名例程。 重载使我们可以拥有多个共享相同名称,但参数和类型数量不同的例程。

As an example, let's consider the following two functions:

作为示例,让我们考虑以下两个功能:

{Overloaded routines must be declared
with the overload directive}
function SumAsStr(a, b :integer): string; overload
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值