How to declare two inter-linked classes?

前端 未结 3 1275
暗喜
暗喜 2020-12-04 01:46

I have a question similar to this, but in delphi.

type
  TThreadPopulator = class(TThread)
  private
    _owner:TASyncPopulator; //Undeclared identifier
  en         


        
3条回答
  •  暖寄归人
    2020-12-04 02:31

    Besides using a forward declaration, you can also create a subclass to solve this:

    TThreadPopulator = class(TThread)
      type 
        TAsyncPopulator = class 
          _updater: TThreadPopulator;  
        end;
    
      var 
        owner: TAsyncPopulator;
    end;
    

提交回复
热议问题