> class B;
class A
{
public:
B monkey;
}
class B
{
public:
A ape;
}
Been thinking about this.
Have you ever held a small mirror up to a big full length mirror, and then
looked into the full length mirror? You see an image of the small mirror,
and inside it is the image of the full length mirror, and inside that is the
image of the small mirror, and inside that is the image of the full length
mirror, and inside that is the image of the small mirror, and inside that is
the image of the full length mirror, and inside that is the image of the
small mirror, and inside that is the image of the full length mirror, and
inside that is the image of the small mirror, and inside that is the image
of the full length mirror, and inside that is the image of the small mirror,
and inside that is the image of the full length mirror... and on and on to
eternity.
Well that's what's happening with my code above.
When you declare a class A:
A Bubbles;
That Bubbles contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A, and that A contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A, and that A contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A, and that A contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A, and that A contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A, and that A contains a B, and that B contains an A, and that A contains a
B, and that B contains an A, and that A contains a B, and that B contains an
A... and on and on to enternity.
sizeof(A) = Infinity
sizeof(B) = Inifinity
Other than that, to declare the A class, you've to know the specifics of the
B class, so define the B class first. But then the B class needs to know the
specifics of the A class, so define the A class first. But then the A class
needs to know the specifics of the B class, so define the B class first. But
then the B class needs to know the specifics of the A class, so define the A
class first. But then the A class needs to know the specifics of the B
class, so define the B class first. But then the B class needs to know the
specifics of the A class, so define the A class first. But then the A class
needs to know the specifics of the B class, so define the B class first...
-JKop