is overload invalid for methods?

Posted by Diane Channers on June 02, 2007

In Reply to Re: overloaded functions and procedures posted by Jenny, DelphiLand Team on May 31, 2007

Thank you Jenny for your speedy answer! I have been playing around with Delphi overloading and now I have another question.

Why do I get this error:
"Method FirstPart with identical parameters already exists"?

I have declared two methods with the same name "FirstPart" but with different parameters. The names of the parameters are different: S and S2. And their types are different: one is passed "by value", the other is passed "by reference". And they are in different types of routines, a function and a procedure. What is wrong? Is overload invalid for methods, maybe it can only be used for "normal" routines?

This is what I have in the private section of the unit of Form1:

function FirstPart(S: string): string; overload; 
procedure FirstPart(var S2: string); overload;

This is in the implementation section:

function TForm1.FirstPart(S: string): string;
  Result := Copy(S, 1, Pos('/',S)-1);
procedure TForm1.FirstPart(var S2: string);
  S2 := Copy(S2, 1, Pos('/',S2)-1);

Related articles


Follow Ups