开发者

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!


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;


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜