Delphi方法重载
2024-09-04 10:28:52
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons; type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject); private
Function Maxi(i,y:integer):integer;overload;
Function Maxi(i,x,y:integer):integer;overload;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm}
Function TForm1.Maxi(i,y:integer):integer;
begin
if i>y then Result:=i else Result:=y;
end; Function TForm1.Maxi(i,x,y:integer):integer;
Var
s:integer;
begin
if i>y then s:=i else s:=y;
if s>x then Result:=s else Result:=x;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
Showmessage('10和12的最大值是:'+INTTOSTR(maxi(,)));
end; procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
Showmessage('10和12,15的最大值是:'+INTTOSTR(maxi(,,)));
end; end.
重载:可以通相同的名字,但不同的参数声明多个例程,来重载一个例程名称.为了声明重载例程,使用overload指令.
最新文章
- DB监控-redis监控
- JS~json日期格式化
- TinyXML 在vs2010 VC++使用
- Python File.readlines() 方法
- css3图片墙
- 张江在线APP演示
- 【递推】地铁重组(subway) 解题报告
- TexturePacker文件的反向解析-TextureUnpacker
- C++ typeid实现原理
- django+Python数据库利用Echarts实现网页动态数据显示
- 用Open SSH生成公钥和私钥(Win)
- golang 实现HTTP代理和反向代理
- asp.net core系列 26 EF模型配置(实体关系)
- 133. leetcode-Clone Graph
- 用函数SendARP()获取局域网计算机的MAC地址
- [JZOJ5836] Sequence
- (原创)odoo关系字段在视图中的行为控制 总结
- 解决因为本地代码和远程代码冲突,导致git pull无法拉取远程代码的问题
- 个人作业-Week 2
- redis 慢查询日志