Currently I have a tic tac toe board “tttBoard” with a constructor
tttBoard::tttBoard() {
isX = true;
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
gBoard[x][y]=sEmp;
}
}
}
That should create a new board and fill it with the enum sEmp. isX is a boolean which marks that the first player moves first. Despite having #include "tttBoard.h" and (I believe) having the constructor in that header file (below), I’ve run across the same errors over and over:
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
tttBoard.h
#ifndef tttBoard
#define tttBoard
class tttBoard {
public:
tttBoard();
void Draw();
void Move(int x, int y);
char* getValue(int x, int y);
private:
enum sVal {
sEmp,
sX,
sO
};
sVal gBoard[3][3];
bool isX;
}
#endif
That’s not a proper include guard. You’re defining
tttBoardas an empty symbol and then using the same name for the class.