How to set a forward declaration with generic types under Delphi 2010?

前端 未结 3 954
一个人的身影
一个人的身影 2020-12-01 14:39

I run into what seems to be a very classical problem: An item and a collection class, both referencing each other, that require a forward declaration. I\'m using Delphi 2010

3条回答
  •  独厮守ぢ
    2020-12-01 15:25

    You can work around it by declaring an ancestor class:

    type
      TBaseElement = class
      end;
    
      TMyCollection = class
      end;
    
      TMyElement = class(TBaseElement)
      private
        FParent: TMyCollection;
      end;
    

提交回复
热议问题