加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi – 使用其他单元的接口

发布时间:2020-12-15 09:05:56 所属栏目:大数据 来源:网络整理
导读:我经常得到:我在另一个单元中定义的接口类型的未声明标识符. 这是我有的: unit Drawers;interfaceimplementationtype IDrawer = interface ['{070B4742-89C6-4A69-80E2-9441F170F876}'] procedure Draw(); end;end. unit Field;interfaceuses Graphics,Cla
我经常得到:我在另一个单元中定义的接口类型的未声明标识符.
这是我有的:

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的单元中.

这是关于什么的?

谢谢

解决方法

在单位抽屉中,IDrawer的类型声明必须位于单元的接口部分.您已将其插入到实现部分中,它仅对单元内声明可见.

这是代码:

unit Drawers;

interface

type

  IDrawer = interface
  ['{070B4742-89C6-4A69-80E2-9441F170F876}']
    procedure Draw();
  end;

implementation

end.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读