delphi自定义函数该怎么声明?
unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
implementation
{$R *.dfm}
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
bgein
result:=x+y+z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
isum:integer;
begin
isum:=getsum;
isum:= getsum(10,20,30);
end;
end.
[错误] Unit1.pas(29): Unknown directive: 'bgein'
[错误] Unit1.pas(30): Unknown directive: 'result'
[严重错误] Project1.dpr(5): Could not compile used unit '新建文件夹\Unit1.pas'
不知道那里错了,请高手指点! 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
implementation
{$R *.dfm}
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
bgein
result:=x+y+z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
isum:integer;
begin
isum:=getsum;
isum:= getsum(10,20,30);
end;
end.
[错误] Unit1.pas(29): Unknown directive: 'bgein'
[错误] Unit1.pas(30): Unknown directive: 'result'
[严重错误] Project1.dpr(5): Could not compile used unit '新建文件夹\Unit1.pas'
不知道那里错了,请高手指点! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询