我創建的類SerialForms.pas(17):W1010方法「創建」隱藏了基類型的虛擬方法TComponent「
FormInfo = class (TComponent)
private
FLeftValue : Integer;
FTopValue : Integer;
FHeightValue : Integer;
FWidthValue : Integer;
public
constructor Create(
AOwner : TComponent;
leftvalue : integer;
topvalue : integer;
heightvalue : integer;
widthvalue : integer);
protected
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
function GetChildOwner: TComponent; override;
//procedure SetParentComponent(Value : TComponent); override;
published
property LeftValue : Integer read FLeftValue write FLeftValue;
property TopValue : Integer read FTopValue write FTopValue;
property HeightValue : Integer read FHeightValue write FHeightValue;
property WidthValue : Integer read FWidthValue write FWidthValue;
end;
其進一步用於形式序列化。創建方法有以下實施
constructor FormInfo.Create(AOwner: TComponent; leftvalue, topvalue, heightvalue,
widthvalue: integer);
begin
inherited Create(AOwner);
FLeftValue := leftvalue;
FTopValue := topvalue;
FHeightValue := heightvalue;
FWidthValue := widthvalue;
end;
作爲組裝的結果我收到警告
[dcc32 Warning] SerialForms.pas(17): W1010 Method 'Create' hides virtual method of base type 'TComponent'
,需要什麼讓擺脫這一警告沒有應用的功能丟失?
見,更具可讀性http://docwiki.embarcadero.com/RADStudio/XE3/en/W1010_Method_%27 %25s%27_hides_virtual_method_of_base_type_%27%25s%27_%28Delphi%29 – ain
當您的表單從.dfm文件創建時,它會調用'TComponent'中引入的虛擬構造函數。當表單來自.dfm時,您的構造函數將不會被調用。如果你的構造函數創建了任何對象,那麼你會遇到問題。你的設計可能是錯誤的。 –
要隱藏繼承的'TComponent'虛擬ctor是一個壞主意,如果你想讓額外的ctor使用不同的名稱,比如'CreatePos'。 – kludg