I am getting a compiler error with this header file:
#ifndef GAME1_H # Defined GAME1_H # included "GLGraphics.h" # "DrawBatch.h" class included GameComponent; Class game 1 (Private: GL Graphics Graphics; GameComponent; GameComponent (Game1); GameComponent (Game 1); GameComponent (Game1 Game); zero update (int); zero draw ();} square DrawableGameComponent: public gamecompany {personal: GL graphics graphics; drawback drawback; public: DrawableGameComponent (); DrawableGameComponent (Game1); Zero Draw ();}; # Endif
The problem is that Game1 requires a full definition of GameComponent, and GameComponent requires a full definition of Game1. I had a lot of trouble in different heads, this is the reason why they are together. Can I do this by completely changing the implementation of any of the classes?
Thank you!
Think about the memory of the computer for each other.
clas S B; class A {byte aa; b now;}; square b {byte bb; A BA; }; Ax;
Now the questioner needs to answer how much space should be reserved for x
?
Let's see. The first byte of x
is byte aa;
. Quite easy. This is 1 byte. Next comes b ab;
. Let's see what's there. The first byte of x.ab
is a byte BB
. So far there are 2 bytes for x
. Next, this is a a ba;
. Let's see what's there. The first byte of x.ab.ba
is a byte A;
. This is 3 bytes x
for now.
And so on and furthermore the ad is infinite.
How big is x
? The correct answer is of course *** Outside wheat error ***
.
The compiler does not really do this because it knows that it can not control this case - so the syntax does not allow circular prevention in the first place.
In this example there is a picture of the contents of x
:
UPDATE < / P>
Obviously, I forgot to include a solution here Now that you understand what the problem is, the solution should be very simple. Use pointers to add or a to
a
to a
and b
Already use or on two sides, or after that, you will not have a circular - if in b
A copy of A
is not included, but it has only one indicator, which fixes the whole issue here.
Comments
Post a Comment