delphi custom object constructors and destructors

type
  Tequip = class
  public
    constructor Create();
      destructor destroy(); override;
  private
    btn: Tbutton;
    list: TStringList;
  public
  private
  end;


{ Tequip }

constructor Tequip.Create;
begin
  btn := Tbutton.Create(Form1);
  btn.Top := 10;
  btn.Left := 10;
  btn.Caption := 'btn';
  btn.Height := 30;
  btn.Width := 100;
  btn.Parent := Form1.Panel1;
  list := TStringList.Create;
end;

destructor Tequip.destroy;
begin
  FreeAndNil(btn);
  list.Free;
  inherited Destroy;
end;
 

 

 

 

Published 444 original articles · won praise 25 · views 180 000 +

Guess you like

Origin blog.csdn.net/ozhy111/article/details/103337364