Circular reference fix?
- by SXMC
Hi!
I have a Player class in a separate unit as follows:
TPlayer = class
private
...
FWorld: TWorld;
...
public
...
end;
I also have a World class in a separate unit as follows:
TWorld = class
private
...
FPlayer: TPlayer;
...
public
...
end;
I have done it this way so that the Player can get data from the world via FWorld, and so that the other objects in the world can get the player data in a similar manner.
As you can see this results in a circular reference (and therefore does not work). I have read that this implies bad code design, but I just can't think of any better other way. What could be a better way to do it?
Cheers!