In this question regarding magic numbers in arrays, paxdiablo says that any number other than -1, 0 and 1 are magic numbers. I know that this is only a guideline but I was wondering if when specifying dimensions of a multi dimensional array if I needed to define constants for which dimension was x, y and z. For example, is this okay:
typedef boost::multi_array<TileID, 3> TileArray3D;
TileArray3D::size_type GoRPG::MapData::GetWidth() {
return mData.shape()[0];
}
or is this preferred:
TileArray3D::size_type GoRPG::MapData::GetWidth() {
return mData.shape()[x_dimension];
}
Thanks in advance, ell.
Edit: The reason the lengths are stored in an array is because I am using Boost::multi_array and that is how they are stored. Apologies for the broken code! I can fix that later - at the moment I just would like to know about the magic numbers, although it is still useful, thank you!