我收到此头文件的编译器错误:
#ifndef GAME1_H
#define GAME1_H
#include "GLGraphics.h"
#include "DrawBatch.h"
class GameComponent;
class Game1 {
private:
GLGraphics graphics;
GameComponent components;
void updateDelegates();
void Run();
};
class GameComponent {
private:
static int index;
protected:
Game1 game;
public:
GameComponent();
GameComponent(Game1 game);
void Update(int);
void Dispose();
};
class DrawableGameComponent: public GameComponent
{
private:
GLGraphics graphics;
DrawBatch drawBatch;
public:
DrawableGameComponent();
DrawableGameComponent(Game1);
void Draw();
};
#endif
Run Code Online (Sandbox Code Playgroud)
我发现问题是Game1需要GameComponent的完整定义,而GameComponent需要Game1的完整定义.我在单独的标题中有这些太麻烦了,所以这就是他们在一起的原因.如果没有完全改变其中一个类的实现,我有什么方法可以做到这一点?
谢谢!