我想重载一个类中的过程。 为此,我写道:
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;
但delphi告诉我有关前向或外部声明错误的错误......
为什么会这样?
提前感谢!
答案 0 :(得分:11)
你必须添加班级名称......
implementation
procedure TMyClass.dosomething(filename:string);
begin
end;
procedure TMyClass.dosomething(s: string; t: string; u: string);
begin
end;
答案 1 :(得分:2)
它可能告诉您缺少构造函数和析构函数的实现。该程序编译:
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.