Delphi - 使用另一个单元的接口
我不断收到:我在另一个单元中定义的接口类型的未声明标识符。 这是我所拥有的:
unit Drawers;
interface
implementation
type
IDrawer = interface
['{070B4742-89C6-4A69-80E2-9441F170F876}']
procedure Draw();
end;
end.
unit Field;
interface
uses
Graphics, Classes, Drawers;
TField = class(TInterfacedObject, IField)
private
FSymbolDrawer: IDrawer;
在 FSymbolDrawer 我收到编译器错误。
当然我有抽屉的用途;以定义 TField 的单位表示。
这是关于什么的?
谢谢
I am constantly getting the: Undeclared identifier for an interface type I have defined in another unit.
Here is what I have:
unit Drawers;
interface
implementation
type
IDrawer = interface
['{070B4742-89C6-4A69-80E2-9441F170F876}']
procedure Draw();
end;
end.
unit Field;
interface
uses
Graphics, Classes, Drawers;
TField = class(TInterfacedObject, IField)
private
FSymbolDrawer: IDrawer;
At FSymbolDrawer I get the complier error.
Of course I have the uses Drawers; in the unit where TField is defined.
What's this about?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在单元
Drawers
中,IDrawer
的类型声明必须位于单元的接口部分。您已将其插入到实现部分中,该部分仅对单元内声明可见。这是代码:
In the unit
Drawers
the type declaration ofIDrawer
has to be in the interface part of the unit. You have inserted it in the implementation part where it is only visible for in-unit declarations.Here is the code:
您将
Drawers
添加到哪个uses 子句中?它必须位于interface
使用子句中(位于使用它的TField
定义之上)。Which uses clause do you add
Drawers
to? It has to be in theinterface
uses clause (above the definition ofTField
that uses it).