Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delphi overloading procedure

i want to overload a procedure in a class. for this i wrote:

type 

  TMyClass = class(TObject)
  private...
  ...
  public 
   constructor create;
   destructor destroy;
   procedure dosomething(filename: string); overload;
   procedure dosomething(s: string; t: string; u: string); overload;


implementation

  procedure dosomething(filename:string);
  begin
  end;

  procedure dosomething(s: string; t: string; u: string);
  begin
  end;

but delphi tells me an error regarding forward- or external declaration error...

why is that?

thanks in advance!

like image 812
yogi Avatar asked May 10 '11 07:05

yogi


2 Answers

you must add the class name ...

implementation   

procedure TMyClass.dosomething(filename:string);    
begin    
end;

procedure TMyClass.dosomething(s: string; t: string; u: string);    
begin    

end;
like image 184
sdu Avatar answered Sep 28 '22 06:09

sdu


It probably tells you that you are missing the implementation of your constructor and destructor. This program compiles:

program Project1;

{$APPTYPE CONSOLE}

type TMyClass = class(TObject)
  public
    procedure doSomething(const Filename: string); overload;
    procedure doSomething(const s, t, u: string); overload;
end;

{$R *.res}

{ TMyClass }

procedure TMyClass.doSomething(const Filename: string);
begin

end;

procedure TMyClass.doSomething(const s, t, u: string);
begin

end;

begin
  writeln('blubb');
end.
like image 39
Frank Schmitt Avatar answered Sep 28 '22 08:09

Frank Schmitt