So, a Board is a collection of tiles. From a high level perspective, that's all it does. That it's stored as a 1D array, a 2D array, an hash map or a self balancing binary tree does not matter for the user. All that matters is that there are tiles in it.
So, you should instead do it that way:
Tile getTile(int row, int column) const {
return tiles[row][column];
}
Alternatively, return by reference to avoid a copy and/or allow external modifications, but don't forget about const correctness:
const Tile& getTile(int row, int column) const;
Tile& getTile(int row, int column);
Then, if you change your mind and decide to go for a one dimentional array, well, it's easy!
Tile getTile(int row, int column) const {
return tiles[row * 8 + column];
}
The external API does not change, no user code breaks, and everyone can go on with their lives.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…