yogi
yogi

Reputation: 73

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!

Upvotes: 7

Views: 6039

Answers (2)

sdu
sdu

Reputation: 2838

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;

Upvotes: 12

Frank Schmitt
Frank Schmitt

Reputation: 30775

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.

Upvotes: 2

Related Questions