|
From: Shaddow <sh...@ti...> - 2002-05-07 20:24:04
|
I didn't see the original question so I may be answering something that
hasn't actually been asked. If so, just ignore what I have to say.
While it's true that you'd get yourself into all kinds of trouble trying
to have A be a data member of B and B a data member of A, it is entirely
possible (and actually at times necessary) to have B* be a data member
of A and A* be a data member of B. You see this kind of a situation
frequently in frameworks.
class B;
class A
{
B* b;
};
class B
{
A* a;
};
Ioannis Vranos wrote:
>I suppose the question was for me and i suppose the question is to have
>2 classes one containing an object of the other (i did not pay much
>attention when i saw the code).
>
>
>Well this cannot be done and it is good it can't be done, because then
>the computers would crash. :)
>
>
>Imagine the code:
>
>class B;
>
>class A
>{
> B b;
>
>};
>
>class B
>{
> A a;
>};
>
>
>A contains a B which contains an A which contains a B...
>
>
>That's why it can't be done.
>
>Ioannis
>
>* Ioannis Vranos
>* Programming pages: http://www.noicys.cjb.net
>* Alternative URL: http://run.to/noicys
>
>
>>-----Original Message-----
>>From: dev...@li...
>>[mailto:dev...@li...] On Behalf
>>Of Ricardo Lσpez Ruiz
>>Sent: Tuesday, May 07, 2002 9:45 PM
>>To: Dev-C++
>>Subject: Re: [Dev-C++] Foward declaration
>>
>>
>>Then, is there no possibility to program something
>>as Luis Bras propose??...Some special trick, I mean.
>>
>>Ricardo.
>>
>>
>>_______________________________________________________________
>>
>>Have big pipes? SourceForge.net is looking for download
>>mirrors. We supply
>>the hardware. You get the recognition. Email Us:
>>ban...@so...
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>
>_______________________________________________________________
>
>Have big pipes? SourceForge.net is looking for download mirrors. We supply
>the hardware. You get the recognition. Email Us: ban...@so...
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|