|
From: Ioannis V. <no...@ho...> - 2002-05-07 20:54:40
|
Yes, that's rational. I explained why 2 classes can't have objects of
one another both at the same time (1 object occupies at least one byte
even if it belongs to an empty class:
=20
class emtpy{};
=20
).
=20
So it was a situation with an infinite number of objects (and memory)
so it correctly doesn't compile. The situation you describe is ok.
=20
=20
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
<http://www.noicys.cjb.net/>=20
* Alternative URL: http://run.to/noicys
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Shaddow
Sent: Tuesday, May 07, 2002 11:24 PM
To: dev...@li...
Subject: Re: [Dev-C++] Foward declaration
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...=20
[mailto:dev...@li...] On Behalf=20
Of Ricardo L=F3pez 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=20
mirrors. We supply
the hardware. You get the recognition. Email Us:=20
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
|