Mtk wrote:[color=blue]
>
> Victor Bazarov wrote:
>[color=green]
>> Mtk wrote:
>>[color=darkred]
>>> Why does the following, simple, example produce such errors?
>>> I know it has to do with the two header files including each other
>>> and (moreover) the usage of the classes One and Two in the "opposite"
>>> header file... What do I have to do to make this example work?[/color]
>>
>>
>> You can't.
>>
>> Let's condense your example to one file. And let's suppose the compiler
>> knows about classes 'One' and 'Two' somehow _apriori_.
>>[color=darkred]
>> > [...][/color]
>>[color=darkred]
>>> class One
>>> {
>>> public:
>>> One();
>>> private:
>>> Two t;
>>> };[/color]
>>[color=darkred]
>> > [...][/color]
>>[color=darkred]
>>> class Two
>>> {
>>> public:
>>> Two();
>>> private:
>>> One t;
>>> };[/color]
>>
>>
>> Now, what is the size of a class One object? As soon as you can come up
>> with a formula the compiler can use to calculate it, let us know.
>>
>> Meanwhile, look up "forward declaration".
>>
>> V[/color][/color]
[top posting corrected][color=blue]
> Hi!
>
> I forgot to mention that I'm a newbie and I have no intention to make
> the compiler calculate the size of any class at all (at least for now)
> and, thus, I'll skip that part.
>[/color]
That's not a good idea; understanding this is *absolutely central* to
your understanding of why you can't do what you're trying to do.
[color=blue]
> I just want class One to have a variable of the "class Two"-type and
> vice-versa, giving the requirement that each class is located in its own
> header file.[/color]
Right. See above.[color=blue]
>
> I'll look "forward declarations" up.
>[/color]
HTH,
--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"