使用泛型的前向声明

时间:2014-08-25 14:06:42

标签: delphi generics delphi-xe6

那么如何使用泛型进行正确的声明?

type
  TGenericCollectionItem = class;

  TGenericCollection<T: TGenericCollectionItem> = class(TObjectList<T>) // line 14
  protected
    procedure Notify(const Value: T; Action: TCollectionNotification); override;
  end;

  TGenericCollectionItem = class
  public
    Owner: TGenericCollection<TGenericCollectionItem>;
  end;

[dcc32错误] Project1.dpr(14):E2086类型'TGenericCollectionItem'尚未完全定义

0 个答案:

没有答案