【发布时间】:2012-07-11 13:59:43
【问题描述】:
这是给我错误的代码:
TAdvSmoothDockItems = class(TCollection)
private
FOwner: TAdvSmoothDock;
FOnChange: TNotifyEvent;
protected
function GetItem(Index: Integer): TAdvSmoothDockItem; virtual; //YLM_TMS_01
procedure SetItem(Index: Integer; const Value: TAdvSmoothDockItem); virtual; //YLM_TMS_01
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TAdvSmoothDock); overload; virtual; //YLM_TMS_01
function Add: TAdvSmoothDockItem; virtual; //YLM_TMS_01
function Insert(Index: Integer): TAdvSmoothDockItem; virtual; //YLM_TMS_01
property Items[Index: Integer]: TAdvSmoothDockItem read GetItem write SetItem; default;
procedure Delete(Index: Integer); virtual; //YLM_TMS_01
published
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TKHAdvSmoothDockItems = class(TAdvSmoothDockItems)
private
FOwner: TKHAdvSmoothDock;
FOnChange: TNotifyEvent;
protected
function GetItem(Index: Integer): TKHAdvSmoothDockItem; override;
procedure SetItem(Index: Integer; const Value: TKHAdvSmoothDockItem); override;
function GetOwner: TPersistent; override;
public
constructor Create(AOwner: TKHAdvSmoothDock);
function Add: TKHAdvSmoothDockItem;
function Insert(Index: Integer): TKHAdvSmoothDockItem;
property Items[Index: Integer]: TKHAdvSmoothDockItem read GetItem write SetItem; default;
procedure Delete(Index: Integer); override;
published
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
这段代码给了我以下错误:
“GetItem”的 E2037 声明与之前的声明不同
为什么?我已将基类中的 GetItem 声明为“虚拟”,然后我尝试在下一个类(TKHAdvSmoothDockItems)中覆盖它......?如何解决?
【问题讨论】:
-
我想你想覆盖属性类型。看看这个:docwiki.embarcadero.com/RADStudio/en/…
-
考虑使用
reintroduce。看到这个:stackoverflow.com/questions/741735/… -
这不是同一个问题,@Rba。此问题要求对错误消息进行解释。错误消息甚至从未出现在上一个问题中。这个问题源于另一个问题,但它们并不相同。这是一个后续问题,但它也可以独立存在。
-
正是@RBA..这不是同一个问题..这里要求对错误消息进行解释!
标签: delphi overriding