//带默认值的参数只能在后面
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;

posted on 2007-12-06 17:23  万一  阅读(4765)  评论(3编辑  收藏  举报