unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TBaseClass=Class
protected
function GetValue: Integer;
virtual;
Procedure SetValue(aValue:Integer);
virtual ;
published
Property Value:Integer
read GetValue;
End;
TFirstClass=Class(TBaseClass)
private
FValue:Integer;
protected
function GetValue: Integer;
override;
Constructor Create;
End;
TSecondClass=Class(TBaseClass)
private
FValue:Integer;
protected
function GetValue: Integer;
override;
Procedure SetValue(aValue:Integer);
override;
published
Property Value:Integer
read GetValue
write SetValue;
End;
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TBaseClass }
{ TFirstClass }
constructor TFirstClass.Create;
begin
inherited;
FValue := 17;
end;
function TFirstClass.GetValue: Integer;
begin
Result := FValue;
end;
{ TSecondClass }
function TSecondClass.GetValue: Integer;
begin
Result := FValue;
end;
procedure TSecondClass.SetValue(aValue: Integer);
begin
inherited;
FValue := aValue;
end;
{ TBaseClass }
function TBaseClass.GetValue: Integer;
begin
//
end;
procedure TBaseClass.SetValue(aValue: Integer);
begin
Showmessage('
Set Value from base')
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
With TFirstClass.Create
do
try
// Value := 13; geht nicht
Showmessage(IntToStr(value));
finally
free;
end;
With TSecondClass.Create
do
try
Value := 13;
Showmessage(IntToStr(value));
finally
free;
end;
end;
end.