I'm trying to write a board game playing program (in C++). I have 2 classes called Move and Board. In my Board constructor, I am using a pair<char, Move>. It seems like it is not recognizing the class Move, even though I #include it in the header file. I get the error message: "missing ',' before identifier 'coord' " and " 'coord' : undeclared identifier". Here is my code:
Move.h:
#include <utility>
#include <vector>
using namespace std;
class Move{
private:
pair<int,int> coordinates;
public:
Move(int,int);
};
Move.cpp:
#include "Move.h"
Move::Move(int x, int y){
coordinates.first = x;
coordinates.second = y;
}
Board.h:
#include "Move.h"
class Board{
private:
vector<pair<char, Move> > board_state;
public:
Board(vector<pair<char, Move> >);
};
Board.cpp:
#include "Board.h"
Board::Board(vector<pair<char P, Move coord> > state){
board_state = state;
}
The template arguments for pair should be types only. So vector<pair<char P, Move coord>> should read vector<pair<char, Move>>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With