class Player pX
{
private:
char player;
public:
int evalMove(int col, Board b)
{
//horizontal
for (int row = 0; row < 6; row++)
{
for (int col = 0; col < 4; col++)
{
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player &&
board[row][col+3] == player)
return 100;
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player)
return 75;
if (board[row][col] == player &&
board[row][col+1] == player)
return 50;
if (board[row][col] == player)
return 25;
}
}
//vertical
for (int row = 0; row < 3; row++)
{
for (int col = 0; col < 7; col++)
{
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player &&
board[row][col+3] == player)
return 100;
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player)
return 75;
if (board[row][col] == player &&
board[row][col+1] == player)
return 50;
if (board[row][col] == player)
return 25;
}
}
//upright diagonal
for (int row = 5; row > 2; row--)
{
for (int col = 0; col < 4; col++)
{
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player &&
board[row][col+3] == player)
return 100;
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player)
return 75;
if (board[row][col] == player &&
board[row][col+1] == player)
return 50;
if (board[row][col] == player)
return 25;
}
}
//down right diagonal
for (int row = 5; row > 2; row--)
{
for (int col = 6; col > 2; col--)
{
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player &&
board[row][col+3] == player)
return 100;
if (board[row][col] == player &&
board[row][col+1] == player &&
board[row][col+2] == player)
return 75;
if (board[row][col] == player &&
board[row][col+1] == player)
return 50;
if (board[row][col] == player)
return 25;
}
}
}
};
My problem here is that I keep getting the error that 'board' isn't defined, and I need to take 'board' from a different class and use it here. Board is identified here
You are passing a Board b but then you just attempt to access it like it is an array, and you are also calling it 'board'. Use your member functions in Board in order to get the array.