|
|
>> I'm currently trying to work out how I can compile a program where
>> module 1 refers to module 2, but module 2 also refers to module 1. As
>> far as I can figure out, this is impossible...
>
> The only thing that's impossible for a class to have another class
> as member variable, and that another class having the first class as
> member variable.
Yeah, that's exactly what I'm trying to do.
Actually, no, wait... Class X has class Y as a member, but class Y only
/mentions/ class X. (It has member functions that return objects of
class X.)
> (For obvious reasons. It would be an infinitely large class.)
It can if at least one of the classes refers to the other through a
pointer or a reference. (Think about it: A binary tree class has no
problem containing /itself/ as a member variable or two.)
So, the way I see it, I have two options:
1. Put class X and class Y in the same header file.
2. Start throwing unchecked casts around the place.
Post a reply to this message
|
|