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

无法在Delphi 2010中获得前瞻性声明

发布时间:2020-12-15 04:08:33 所属栏目:大数据 来源:网络整理
导读:我完全无法在Delphi 2010中获得类声明.我已经阅读了文档,在网上阅读,也许我是一个白痴,但我无法得到任何编译.任何帮助都将受到大力赞赏! 我敲了这两个米老鼠班.当然我知道他们需要构造函数等来实际工作,它只是我正在解决的问题的演示. 我有MyParent类,其中
我完全无法在Delphi 2010中获得类声明.我已经阅读了文档,在网上阅读,也许我是一个白痴,但我无法得到任何编译.任何帮助都将受到大力赞赏!

我敲了这两个米老鼠班.当然我知道他们需要构造函数等来实际工作,它只是我正在解决的问题的演示.

我有MyParent类,其中包含我的其他类MyChild的TList.没关系.但是在MyChild中我希望能够设置对其父对象的引用,而不是TList而是MyParent类.

unit ForwardClassDeclarationTest;

interface

uses generics.collections;        

type
  MyChild = Class
  private
    ParentObect:MyParent;   <--I need to be able to make this accessable
  public
End;

type
  MyParent = Class
  public
    tlChildren:TList<MyChild>;
End;

implementation

end.

我需要在这两个课程之前创建一个前向声明,但我完全无法得到任何结果.提前感谢任何倾向于帮助我的人.

解决方法

@csharpdefector试试这段代码
uses
  Generics.Collections;

type
   MyParent = Class;   // This is a forward class definition

  MyChild = Class
  private
    ParentObect:MyParent;
  public
  End;

  MyParent = Class // The MyParent class is now defined
  public
    tlChildren:TList<MyChild>;
  end;

implementation

end.

欲了解更多信息,你可以在delphibasics看到这个link

(编辑:李大同)

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

    推荐文章
      热点阅读