Versuch es mit einer virtuellen Testmethode.
Delphi-Quellcode:
TOberklasse = class(TObject)
protected
function TestMethode: string; virtual;
public
class procedure Test(AObj: TOberklasse);
constructor Create;
end;
TUnterklasse = class(TOberklasse)
protected
function TestMethode: string; override;
public
Name: String;
constructor Create;
end;
implementation
class procedure TOberklasse.Test(AObj: TOberklasse);
begin
if Assigned(AObj) then
ShowMessage(AObj.TestMethode);
end;
procedure TOberklasse.TestMethode;
begin
Result := 'ClassName = ' + ClassName;
end;
procedure TUnterklasse.TestMethode;
const
CRLF = #13#10;
begin
Result :=
inherited TestMethode + CRLF +
'Name = ' + Name;
end;