考虑假设的对象层次结构,从以下开始:
TFruit = class(TObject)
public
constructor Create(Color: TColor); virtual;
end;
Run Code Online (Sandbox Code Playgroud)
及其后代:
TApple = class(TFruit)
public
constructor Create(); overload; virtual;
constructor Create(Color: TColor); overload; override; //deprecated. Calls other constructor - maintaining the virtual constructor chain
end;
Run Code Online (Sandbox Code Playgroud)
这里的想法是我已经覆盖了基类的虚构造函数,其重载也恰好是虚拟的.
德尔福抱怨:
方法'Create'隐藏基类型'TFruit'的虚方法
除了它不隐藏它 - 它就在那里!
这是怎么回事?