Registriert seit: 12. Aug 2003
Ort: Soest
4.027 Beiträge
Delphi 10.1 Berlin Enterprise
|
Re: Mal wieder Klassenvererbung
24. Jun 2004, 16:14
So genehm?
Delphi-Quellcode:
unit frVererbung;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TGeometrie = class(TPersistent)
constructor Create; virtual; abstract;
end;
TKugel = class(TGeometrie)
constructor Create; override;
end;
TQuader = class(TGeometrie)
constructor Create; override;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TQuader }
constructor TQuader.Create;
begin
inherited;
ShowMessage(ClassName);
end;
{ TKugel }
constructor TKugel.Create;
begin
inherited;
ShowMessage(ClassName);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TGeometrie(FindClass(' TKugel').Create).Create;
TGeometrie(FindClass(' TQuader').Create).Create;
end;
initialization
RegisterClass(TKugel);
RegisterClass(TQuader);
finalization
UnRegisterClass(TKugel);
UnRegisterClass(TQuader);
end.
|
|
Zitat
|