I’m trying to describe a Sudoku Board in C++ with a union statement:
union Board
{
int board[9][9];
int sec1[3][3];
int sec2[3][3];
int sec3[3][3];
int sec4[3][3];
int sec5[3][3];
int sec6[3][3];
int sec7[3][3];
int sec8[3][3];
int sec9[3][3];
}
Would each section of the board correspond with the correct part of the array? IE,
Would sec4 correspond with board[4-6][0-3]? Is there a better way to do this sort of thing (specifically describing a sudoku board)?
You could achieve the effect you want by encapsulating it in a class:
but, I’m not sure this is the best way to represent a Sudoku board. You may find that once you start working on the logic, you’ll come up with a better representation.