I am creating a Game in openGl and I encountered a problem which is bugging me for nearly 2 hours now. Main function is in readobj.cpp which includes World.h, I have a World.h file which uses Ball.h and Stick.h. In the other hand there is a Game.h file which is being used by both Ball.h and Stick.h.
World.h
#include "Ball.h"
#include "Camera.h"
#include "Stick.h"
class World
{
Ball ball[15];
Ball qBall;
Camera camera;
public:
World();
void update();
void render();
};
Stick.h
#include "Game.h"
class Stick
{
point power;
public:
void setPosition(point);
void setPower(point);
void render();
void update();
};
Ball.h
#include "Game.h"
class Camera
{
public:
Camera();
void update();
void render();
};
Game.h
class point {
public:
double x,y,z;
};
The error that i am getting is
g++ -Wall -c readobj.cpp -L. -lBall -lWorld -lCamera -lStick
In file included from Camera.h:1:0, from World.h:2, from readobj.cpp:12:
Game.h:1:7: error: redefinition of ‘class point’
Game.h:1:7: error: previous definition of ‘class point’
In file included from Stick.h:1:0,
from World.h:3,
from readobj.cpp:12:
Game.h:1:7: error: redefinition of ‘class point’
Game.h:1:7: error: previous definition of ‘class point’