Does not name a type?

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


Space.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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();
		virtual void setTop(Space* t)=0;
		virtual void setBottom(Space* b)=0;
		virtual void setLeft(Space* l)=0;
		virtual void setRight(Space* r)=0;
		
		virtual void describeRoom()=0;
		virtual Player* explore(Player* p)=0;
};

#endif 



Player.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include "Space.hpp"

// Player class declaration

class Player
{
	private:
		Space* currentRoom;

	public:
		Player();
		~Player(){}
		
		void setCurrentRoom(Space* s);
		int getCurrentRoom();
};

#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
Topic archived. No new replies allowed.