1
type
TObjA = class
a: string;
end;
type
worker<T> = interface
function step1(v: integer): T;
function step2(s: string): T;
end;
type
ImplA<T> = class(TInterfacedObject, worker<T>)
function step1(v: integer): T;
function step2(s: string): T; virtual; abstract;
end;
type
ImplB = class(ImplA<TObjA>)
function step2(s: string): TObjA;
end;
implementation
function ImplA<T>.step1(v: integer): T;
begin
result := step2(IntToStr(v));
end;
function ImplB.step2(s: string): TObjA;
var
r: TObjA;
begin
r := TObjA.Create;
r.a := 'step2 ' + s;
result := r;
end;
我試圖根據此結構構建功能。我知道它在java中工作,但目前我在delphi 2010工作。 當調用ImplB.step1(1) 我得到一個抽象的錯誤我該如何解決這個問題?擴展類時出現抽象錯誤
謝謝,就是這樣。我所要做的只是添加override關鍵字。 :) – GMEFil 2013-03-18 16:19:11