unit uMain;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm1 =
class(TForm)
lblA: TLabel;
lblB: TLabel;
btn1: TButton;
btn2: TButton;
btn3: TButton;
procedure btn1Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Type
TObjectA =
class
strict private const
cTestValue = '
aaa';
public
Function testvalue:
String;
virtual;
Procedure MachWasMitTestValue;
end;
TObjectB =
class(TObjectA)
strict private const
cTestValue = '
bbb';
public
Function testvalue:
String;
override;
end;
procedure TObjectA.MachWasMitTestValue;
begin
ShowMessage(testvalue);
end;
function TObjectA.testvalue:
String;
begin
Result := cTestValue;
end;
function TObjectB.testvalue:
String;
begin
Result := cTestValue;
end;
procedure TForm1.btn1Click(Sender: TObject);
var ObjectA:TObjectA;
begin
ObjectA := TObjectA.Create;
try
lblA.Caption:=ObjectA.testvalue;
//ObjectA.MachWasMitTestValue;
finally
ObjectA.Free;
end;
ObjectA.MachWasMitTestValue;
end;
procedure TForm1.btn2Click(Sender: TObject);
var ObjectB: TObjectB;
begin
ObjectB:=TObjectB.create;
try
lblB.Caption:=ObjectB.testvalue;
ObjectB.MachWasMitTestValue;
finally
ObjectB.free;
end;
end;
procedure TForm1.btn3Click(Sender: TObject);
begin
close;
end;
end.