I am getting an EXC BAD ACCESS error. Not sure what the problem is. I am trying to test the cells inside the 2d vector. I would like it to print a grid of 0's 20x20
struct Cell {
int test;
Cell(): test(0) {}
};
class Board {
public:
Board() {
for (int i = 0; i < 20; i++) {
Cell temp;
cellVec[i].resize(20, temp);
}
}
friend ostream& operator<<(ostream& out, const Board& boardPrint) {
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
out << boardPrint.cellVec[i][j].test;
}
}
return out;
}
private:
vector< vector<Cell> > cellVec;
};
int main() {
Board newBoard;
cout << newBoard;
}