Im struggling to understand how I can declare an array in a class and use it within all functions in that same class. The arrays size is dependant on the user .
class Game{
public:
void createBoard();
void gameStart();
void inputBoard();
void inputBoardSize();
Game(int,int);
private:
int rowChoice;
int colChoice;
int playerTurnRow;
int playerTurnCol;
string playerTurn;
string board[rowChoice][colChoice];
};
Game::Game(int row,int col){
rowChoice = row;
colChoice = col;
playerTurnRow = 0;
playerTurnCol = 0;
playerTurn = "R";
board[row][col];
}
void Game::createBoard(){
for (int arrayRow = 0;arrayRow < rowChoice;arrayRow++){
for (int arrayCol = 0;arrayCol < colChoice;arrayCol++){
board[arrayRow][arrayCol] = " ";
}
}
My declaration might be wrong but any help would be appreciated