Hello, I'm trying to have 2 classes include the other. But for one of them it says that it does not name a type. The error:
In file included from Space.hpp:9:0,
from Space.cpp:6:
Player.hpp:17:3: error: ‘Space’ does not name a type
Space* currentRoom;
^
Player.hpp:25:23: error: ‘Space’ has not been declared
void setCurrentRoom(Space* s);
^
make: *** [Space.o] Error 1
#ifndef SPACE_HPP
#define SPACE_HPP
#include "Player.hpp"
class Space
{
protected:
Space* top; //pointer to linked space above
Space* bottom; //pointer to linked space below
Space* left; //pointer to linked space left
Space* right; //pointer to linked space right
int roomNum;
public:
Space();
~Space();
virtualvoid setTop(Space* t)=0;
virtualvoid setBottom(Space* b)=0;
virtualvoid setLeft(Space* l)=0;
virtualvoid setRight(Space* r)=0;
virtualvoid describeRoom()=0;
virtual Player* explore(Player* p)=0;
};
#endif
I figured it out. I had to use a class declaration for one of them. So in space I just put a
class Player;
instead of #include "Player.hpp"
and that fixed it