参数默认值
程序员文章站
2024-02-20 19:32:28
...
//带默认值的参数只能在后面
function MyFun(a:Integer; b:Integer=1; c:Integer=2): Integer;
begin
Result := a + b + c;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
x: Integer;
begin
x := MyFun(1);
ShowMessage(IntToStr(x)); //4
x := MyFun(1,2);
ShowMessage(IntToStr(x)); //5
x := MyFun(1,2,3);
ShowMessage(IntToStr(x)); //6
end;
转载于:https://my.oschina.net/hermer/blog/319378
上一篇: js.Reflect