码迷,mamicode.com
首页 > 数据库 > 详细

Handbook之010:函数重载

时间:2015-10-23 18:31:45      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

可以修改如下:

技术分享

或者如下:

技术分享

 

代码如下:

unit Unit1;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function Add(N: Integer; S: Single): Single; overload;
begin
  Form1.Memo1.Lines.Add(重载方法一);
  Result := N + S;
end;

function Add(S: Single; N: Integer): Single; overload;
begin
  Form1.Memo1.Lines.Add(重载方法二);
  Result := N + S;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Add(10, 10.ToSingle);
end;

end.

Handbook之010:函数重载

标签:

原文地址:http://www.cnblogs.com/GodPan/p/4905176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!