[Lazarus] OOP basics - 2

Kjow antispammoni at gmail.com
Wed Apr 14 18:06:48 CEST 2010


2010/4/14 John vd Waeter <john at jvdw.nl>:
> You cannot refer to unitX in the interface section of unitY AND at the same
> time refer to unitY in the interface section of unitX.
>
> The compiler sees unitX needs unitY and so will try to compile unitY first.
> In unitY it sees unitX is needed and wants to compile unitX first and so on.
> Hence: circular reference.
>
> If unitX needs unitY and vice versa, at least in one of them the reference
> to the other unit should be moved to the implementation section.

Yes, I know, but how to use a class that is declared on different unit
if it is needed before the implementation section?

In my example:

1) I need on unit1 (for a method, so in the type section) the TTest on unit3
2) I need on unit3 (for a method, so in the type section) the TForm1 on unit1

in both cases I can't declare each unit on implementation section,
cause they are needed before the section.

is not possible?

Kjow




More information about the Lazarus mailing list