【发布时间】:2009-03-18 17:05:38
【问题描述】:
在一个文件中,我有一个带有 ID 属性的基类:
type
TBase = class(TObject)
private
FID: integer;
public
property ID: integer read FID write SetID;
end;
在第二个文件中,我有另一个类,从 TBase 下降。出于偶然、无知或其他原因,创建了一个与现有属性/字段同名的新属性/字段。
type
TSub = class(TBase)
private
FID: Longword;
public
property ID: Longword read FID write FID;
end;
第二个 ID 字段当然是重命名的,但为什么编译器允许这样做呢?
在代码中访问 ID 时 - 使用哪个 ID 字段?
【问题讨论】:
标签: delphi inheritance properties