Delphi中具有不同参数类型的函数

时间:2015-06-30 17:37:58

标签: delphi

如何使用不同的参数类型编写两个具有相同名称的函数,如下所示:

  public
    { Public declarations }
    function MsgW(const Msg:String):Integer;
    function MsgW(const Msg:String;title:String):Integer;


function MsgW(const Msg:String;title:String):Integer;
Begin
  Result := MessageboxW(0,Pchar(Msg),Pchar(title),MB_OK);
End;

function MsgW(const Msg:String):Integer;
Begin
  Result := MessageboxW(0,Pchar(Msg),'MessageBoxW',MB_OK);
End;

1 个答案:

答案 0 :(得分:11)

使用overload指令

function MsgW(const Msg:String):Integer; overload;
function MsgW(const Msg:String;title:String):Integer; overload;

Overloading Methods

相关问题