我有一个接口和一个相应的对象。例如...
IMyInterface = interface
function GetSomething: WideString;
procedure SetSomething(const Value: WideString);
property Something: WideString read GetSomething write SetSomething
end;
TMyObject = class(TInterfacedObject, IMyInterface)
private
function GetSomething: WideString;
procedure SetSomething(const Value: WideString);
public
property Something: WideString read GetSomething write SetSomething
end;
我使用此接口能够跨 DLL 与此对象进行交互。
现在我想继承这个对象并覆盖其中一些方法......
TMyOtherObject = class(TMyObject)
private
function GetSomething: WideString; override;
procedure SetSomething(const Value: WideString); override;
除了我想让基本字段虚拟化和抽象化以基本上强制孩子继承这些......
TMyObject = class(TInterfacedObject, IMyInterface)
private
function GetSomething: WideString; virtual; abstract;
procedure SetSomething(const Value: WideString); virtual; abstract;
我可以这样做并让界面仍然适用于这些字段吗?我是否也需要在界面中以这种方式定义它?(我当然知道接口中的所有字段都是抽象的)