I have a file which is strictly for defines, global data, typedefs etc...
gamedata.h
#include <utility>
#include "player.h"
namespace GameData {
enum Color {
BLACK = 0,
WHITE = 1
};
typedef typename std::pair<char, int> Position;
typedef typename std::pair< std::pair<char, int>, std::pair<char, int> > Move;
typedef typename std::pair<Player*, Player*> Players;
};
I am having two problems:
(1) Player class is not found - even though I've included it with the header
#include <string>
#include "board.h"
#include "gamedata.h"
class Player {
public:
virtual ~Player() {}
virtual Move getMove(Board &c) = 0;
};
(2) The Move getMove
function in the player header cannot resolve Move
`Move` does not name a type
My best guess is that this is happening because it is a circular include where both need to include each other.
So I forward declare Player in gamedata.h
class Player;
namespace GameData {
enum Color {
BLACK = 0,
WHITE = 1
};
typedef typename std::pair<char, int> Position;
typedef typename std::pair< std::pair<char, int>, std::pair<char, int> > Move;
typedef typename std::pair<Player*, Player*> Players;
};
Which fixes the Player problem, but now the move is still wonky.
// None work
GameData::Move
Move
Code:
Edit 1
I would like to change this:
typedef typename std::pair< std::pair<char, int>, std::pair<char, int> > Move;
to
typedef typename std::pair<Position, Position> Move;
But I thought it was producing the error so I didn't revert it back yet.