Data structures have circular references all the time.  For example Employee
and Employer, both are in different units, but both need to reference each
other in their interface.  One solution is to define an abstract employee
class in the employer unit which the real employee class inherits of.
Another option is to use references to TObject, and type casts in the
implementation.  Neither are very elegant though.

I think its more an issue when you store a lot of data in objects.  IMHO,
user interface dependencies tend to be more heirachical.

Wilfred.

-----Original Message-----
From: Kerry Sainsbury [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 19 August 1999 09:05
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Circular unit references - gotta love'm!


--- Nahum Wild <[EMAIL PROTECTED]> wrote:
> Does anyone know how to get around the following issue where I have
> two
> different classes that each contain a reference to the other in their
> definition, the problem being that I want them in different units.  
> As
> predicted delphi spits a 'circular reference' error at me. :s(

My honest answer would be to suggest that you shouldn't write code like
that :-) You don't want to create such dependencys between your classes
-- it makes reuse too tricky.

What's your real-world example? Perhaps we can think of a more elegant
solution to the problem.


===
Cheers,
Kerry S
-- Systems Engineer, Inprise NZ. [EMAIL PROTECTED]
_______________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com.au address at http://mail.yahoo.com.au

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to