RepeatUntil
RepeatUntil

Reputation: 2320

Function with different parameter type in Delphi

How can I write two functions with the same name with different parameter types like this:

  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;

Upvotes: 3

Views: 779

Answers (1)

Dalija Prasnikar
Dalija Prasnikar

Reputation: 28516

Use overload directive

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

Overloading Methods

Upvotes: 12

Related Questions