I'm building a C++ project in Eclipse using a third party implementation of gcc. The makefile is auto-generated and the object rules are listed in alphabetical order ( I'm not sure if that's relevant ).
I can't seem to create the correct configuration of #include directives and forward declarations so that it compiles. I'm guessing - and its clearly a bad case of Voodoo Chicken Coding. Can someone tell me how I should work out the include order?
The problem is that the classes refer to each other (e.g. Display refers to Texture2D and vice versa ).
I have the following files:
Display.cpp
Display.h
Display.h defines the following classes:
class Canvas{ ... };
class Display
{
public:
void PaintTexture(Texture2D * tex);
void WriteText(BitmapFont * fnt);
private:
Canvas * c;
};
and the files:
Texture2D.h
Texture2D.cpp
Texture2D.h defines the following class:
class Texture2D
{
void PaintTo(Canvas * c);
};
and finally the files:
BitmapFont.h
BitmapFont.cpp
BitmapFont as defined in BitmapFont.h refers to both Canvas and Texture2D;
class BitmapFont
{
public:
void Paint(Canvas * c);
private:
Texture2D * tex;
};
main.cpp refers to BitmapFont and Texture2D.