I played around how I can best wrap a Class (TBase) inside a Container that I have limited access to change.
Is this valid Delphi Code? It seems to work.
type TForm1 = class(TForm) procedure FormShow(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; TBase = class public bar: Integer; end; TSpecial = class(TBase) public foo: Integer; end; TBaseContainer = class public base: TBase; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormShow(Sender: TObject); var baseContainer: TBaseContainer; begin baseContainer := TBaseContainer.Create; baseContainer.base := TBase.Create; baseContainer.base.bar := 5; TSpecial(baseContainer.base).foo := 3; ShowMessage(baseContainer.base.bar.ToString); ShowMessage(TSpecial(baseContainer.base).foo.ToString); end;
What does the Compiler do in line "TSpecial(baseContainer.base).foo := 3;"? What memory is used?