Alle Möglichkeiten, welche man offiziell und ohne wildes Rumgepointere zur Verfügung hat
Delphi-Quellcode:
TMyBaseClass = class(TComponent)
procedure DoIt; virtual;
end;
TMyDerivedClass = class(TMyBaseClass)
procedure DoIt; override;
end;
TMyDerivedClass2 = class(TMyBaseClass)
procedure DoIt; override; // no inherited
procedure DoIt_Prev;
end;
procedure TMyBaseClass.DoIt;
begin
Show('TMyBaseClass');
end;
procedure TMyDerivedClass.DoIt;
begin
Show('TMyDerivedClass');
Inherited;
end;
procedure TMyDerivedClass2.DoIt;
begin
Show('TMyDerivedClass 2 no prev');
end;
procedure TMyDerivedClass2.DoIt_Prev;
begin
Inherited;
end;
Delphi-Quellcode:
var Test: TMyBaseClass;
begin
Test := TMyBaseClass.Create;
Test.DoIt;
Test.Free;
Test := TMyDerivedClass.Create;
Test.DoIt;
Test.Free;
Test := TMyDerivedClass2.Create;
Test.DoIt;
Test.DoIt_Prev;
Test.Free;
end;