placeable.h
#include "selectable.h"
class placeable : selectable
{
..
};
selectable.h
#include "game.h"
class selectable
{
..
};
game.h
#include "placeable.h"
class game
{
...
class placeable* holding;
...
};
Basically placeable.h includes selectable.h which includes game.h which includes placeable.h again.
The only solution i can think of is placing the placeable* in a new header, making it static/global and then include this new header in game.h and selectable.h.
I'm sorry i dint include header guards in the upper code. I assumed it was obvious. Header guards does not help in this case because of the inheritance, same thing goes with forward declaring.
Only include headers if you MUST
Use forward declaration in preference to including:
You only need to include the header for class X
iff:
Otherwise a forward declaration will suffice.
// -> Don't do this #include "placeable.h"
class placeable; // forward declare
// Fine if you are using a pointer.
class game
{
...
class placeable* holding;
...
};
PS. Add header guards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With