unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,jpeg, StdCtrls, ExtCtrls;
type
TMasterClass=Class
Class Function WasKannich:Integer;
virtual;
End;
TMasterChildClass1=Class(TMasterClass)
Class Function WasKannich:Integer;
override;
End;
TMasterChildClass2=Class(TMasterClass)
Class Function WasKannich:Integer;
override;
End;
TMasterClassClass=Class
of TMasterClass ;
TForm2 =
class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
CK:TMasterClassClass;
begin
if TMasterChildClass1.WasKannich=2
then CK := TMasterChildClass1
else if TMasterChildClass2.WasKannich=2
then CK := TMasterChildClass2;
With CK.Create
do
begin
Showmessage(IntToStr(WasKannich));
Free;
end;
end;
{ TMasterChildClass2 }
class function TMasterChildClass2.WasKannich: Integer;
begin
Result := 2;
end;
{ TMasterChildClass1 }
class function TMasterChildClass1.WasKannich: Integer;
begin
Result := 1;
end;
{ TMasterClass }
class function TMasterClass.WasKannich: Integer;
begin
Result := 0;
end;
end.