Okay, so essentially I have a struct of a piece on a board, as follows:
struct piece
{
int value;
bool revealed;
bool canMove(int x, int y)
{
//This is where the problem is.
if (board[x][y].value == 13) //If it's not occupied
return true;
else
return false;
}
};
//Define the board
piece board[x][y];
And it's giving me errors such as 'board': undeclared identifier. How can I fix this? I've tried putting the board declaration before the struct, but then it just says that piece is an undeclared identifier.
I realize I could just pass in the board as a parameter, but I have several functions, and that would take a lot more time than I would like, so if there is any other solution, please tell me!
This question is related (but not identical) to Question