Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7031763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:50:45+00:00 2026-05-28T00:50:45+00:00

I have two different classes made in two different units, how do i will

  • 0

I have two different classes made in two different units, how do i will creat circular references? in Delphi(the classes are in different units)

unit1:

Uses unit2;

type Ta = class(tobject)
   public
       b:Tb;
end;

Unit2:

type Tb = class(tobject)
   public
       a:Ta;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:50:46+00:00Added an answer on May 28, 2026 at 12:50 am

    It is indeed possible to circumvent the circular unit reference, using class helpers.

    By adding a common UnitClassHelper including class helpers for both Ta and Tb it could be solved like this :

    unit Unit1;
    
    interface
    
    type Ta = class(tobject)
       public
           b : TObject;
    end;
    
    implementation
    
    uses UnitClassHelper;
    

    –

    unit Unit2;
    
    interface
    
    type Tb = class(tobject)
       public
           a : TObject;
    end;
    
    implementation
    
    uses UnitClassHelper;
    

    –

    unit UnitClassHelper;
    
    interface
    
    uses Unit1,Unit2;
    
    Type TaHelper = Class Helper for Ta
       private
         function GetTb : Tb;
         procedure SetTb( obj : Tb);
       public
         property B : Tb read GetTb write SetTb;
     End;
    
    Type TbHelper = Class Helper for Tb
           private
             function GetTa : Ta;
             procedure SetTa( obj : Ta);
           public
             property A : Ta read GetTa write SetTa;
         End;
    
    implementation
    
    function TaHelper.GetTb: Tb;
    begin
      Result:= Self.B;
    end;
    
    procedure TaHelper.SetTb(obj: Tb);
    begin
      Self.B:= obj;
    end;
    
    function TbHelper.GetTa: Ta;
    begin
      Result:= Self.A;
    end;
    
    procedure TbHelper.SetTa(obj: Ta);
    begin
      Self.A:= obj;
    end;
    
    end.
    

    –

    program Test;
    
    uses
      Unit1 in 'Unit1.pas',
      Unit2 in 'Unit2.pas',
      UnitClassHelper in 'UnitClassHelper.pas';
    
    var
      AObj : Ta;
      BObj : Tb;
    
    begin
      AObj:= Ta.Create;
      BObj:= Tb.Create;
      try
        AObj.B:= BObj;
        BObj.A:= AOBj;
        // Do something
    
      finally
        AObj.Free;
        BObj.Free;
      end;
    end.
    

    See also this excellent summary of class helpers : solving-circular-unit-references-with-class-helpers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes A and B in two different .NET assemblies: AssemblyA and
Let's say we have two classes, Foo and Foo Sub, each in a different
I have two different modules that need access to a single file (One will
I have two different Classes: class X { public int TX1 { get; set;
I have two different classes that share a common interface. Although the functionality is
Say you have two different classes where each have their own implementation of Equals;
I have recently been put in charge of debugging two different programs which will
Say I have two different cpp files. Both declare classes with the same name,
I have two Python classes written in two different files. One is written in
I have two different classes deriving from one base class. They each have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.