如何從各個父類中調用函數,函數應該具有與父類相同的名稱。不同職業等級的德爾福電話函數
在Java中有super
關鍵字,在C#中有base
。德爾福有什麼等價物?
type
MyParentClass = class
function Dosomething: Integer;
end;
MyChildClass = class(MyParentClass)
function DoSomething: Integer;
end;
MyGrandChildClass = class(MyChildClass)
function DoSomething: Integer;
end;
function MyParentClass.Dosomething : Integer;
begin
result := 5;
end;
function MyChildClass.Dosomething : Integer;
begin
result := Dosomething + 15 ; // result should be 20 !
end;
function MyGrandChildClass.Dosomething : Integer;
begin
result := Dosomething + 40 ; // result should be 60 .....
end;
現在應該修復 – user1769184
相關:http://stackoverflow.com/questions/12505695/how-to-access-base-super-class-in-delphi –