Visibility of reintroduced constructor
- by avenmore
I have reintroduced the form constructor in a base form, but if I override the original constructor in a descendant form, the reintroduced constructor is no longer visible.
type
TfrmA = class(TForm)
private
FWndParent: HWnd;
public
constructor Create(AOwner: TComponent; const AWndParent: Hwnd); reintroduce; overload; virtual;
end;
constructor TfrmA.Create(AOwner: TComponent; const AWndParent: Hwnd);
begin
FWndParent := AWndParent;
inherited Create(AOwner);
end;
type
TfrmB = class(TfrmA)
private
public
end;
type
TfrmC = class(TfrmB)
private
public
constructor Create(AOwner: TComponent); override;
end;
constructor TfrmC.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
When creating:
frmA := TfrmA.Create(nil, 0);
frmB := TfrmB.Create(nil, 0);
frmC := TfrmC.Create(nil, 0); // Compiler error
My work-around is to override the reintroduced constructor or to declare the original constructor overloaded, but I'd like to understand the reason for this behavior.
type
TfrmA = class(TForm)
private
FWndParent: HWnd;
public
constructor Create(AOwner: TComponent); overload; override;
constructor Create(AOwner: TComponent; const AWndParent: Hwnd); reintroduce; overload; virtual;
end;
type
TfrmC = class(TfrmB)
private
public
constructor Create(AOwner: TComponent; const AWndParent: Hwnd); override;
end;