Etwas gekünstelt könnte man es so machen:
Delphi-Quellcode:
interface
type
TOpa = class (TObject)
public
procedure SachWas (ARecurse : Integer = 0); virtual;
end;
TVater = class (TOpa)
public
procedure SachWas (ARecurse : Integer = 0); override;
end;
TSohn = class (TVater)
public
procedure SachWas (ARecurse : Integer = 0); override;
end;
implementation
{ TOpa }
procedure TOpa.SachWas (ARecurse: Integer = 0);
begin
ShowMessage ('Hallo Jungs!')
end;
{ TVater }
procedure TVater.SachWas (ARecurse: Integer = 0);
begin
if ARecurse > 0 then
inherited SachWas (ARecurse - 1)
else
ShowMessage ('Hallo Bub!')
end;
{ TSohn }
procedure TSohn.SachWas (ARecurse: Integer = 0);
begin
if ARecurse > 0 then
inherited SachWas (ARecurse - 1)
else
ShowMessage ('GuGu!')
end;
procedure AlleSagenWas(Sender: TObject);
var
kind : TSohn;
begin
kind := TSohn.Create;
try
kind.SachWas;
kind.SachWas(1);
kind.SachWas(2);
finally
kind.Free;
end;
end;