Parameter Type Problem in Delphi Function Overloading

procedure test(value: TDateTime);overload;
begin
  Form1.mmo1.Lines.Add(DateTimeToStr(value));
end;

procedure test(value: Integer);overload;
begin
  Form1.mmo1.Lines.Add(IntToStr(value));
end;

procedure TForm1.btn1Click(Sender: TObject);
var
  a: LongWord;
  b: Cardinal;
  c: Word;
  d: Longint;
begin
  a := 1;
  b := 2;
  c := 3;
  d := 4;
  test(a);
  test(b);
  test(c);
  test(d);
end;


In the actual call, LongWord and Cardinal type parameters will be called to the TDateTime type method.

Guess you like

Origin blog.csdn.net/jhq1990/article/details/47254193