OOP Delphi

If you're writing a derived-class constructor, you'll want to pass the constructor parameters to the base class constructor, as in this example:

constructor TMyButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{ do custom things... }
end;


However, if your derived-class constructor has the same parameters as the base class constructor, you don't have to specify the constructor method name or parameters, and you can simply write:

constructor TMyButton.Create(AOwner: TComponent);
begin
inherited;
{ Do custom things... }
end;


Destructors: you usually should first free your custom allocated members etc. and then call the derived destructor:

destructor TMyButton.Destroy;
begin
{ imagine, you'd have an TStringList member variable }
aStringList.Free;
inherited;
end;