I need a way to access static 2D vector in my static function. The reason being I want to use syntax like GameBoard::initBoard() in my main() function.Observe the following code snippets. I have higlighted error in comments
GameBoard Header
class GameBoard
{
public:
static void initBoard();
protected:
private:
static std::vector <std::vector<char>> chessBoard;
};
InitBoard implementation is as follows
void GameBoard::initBoard()
{
std::vector<char> blankPos {'.','.','.','.','.','.','.','.'};
for(int i{0}; i < 8; i++)
{
chessBoard.push_back(blankPos); //getting Error here
}
}
The error shown is:
undefined reference to `GameBoard::chessBoard'