And thus spake ", India" <>
Sun, 18 Apr 2010 08:12:17 -0700 (PDT):
> In real work environment, which approach is followed ? Kindly explain.
In the real world, you should probably avoid such 'design' at
all costs. Actually, it can never really work. If you use the
second class's interface in an inline function of the first
class, then the interface of the second class has to be known at
that point. So you have to include the complete class definition
beforehand.
Likewise, if the second class wants to use said inline function,
it has to know the complete class definition as well. This is a
'chicken or egg' kind of problem, and cannot be resolved without
some compromise.
The easiest way out would probably be to just use a saner design.
Class dependencies should form an acyclic graph (ideally a
tree). The acyclic property is crucial. If you have dependency
cycles like this, that's a sure sign there is something wrong
with your class structure.
If you can absolutely not avoid havinh dependency cycles (for
whatever reason), you have to use e.g. something like pointer to
implementation, which means you cannot keep everything inlined.
Regards,
Robert
|