What is the maximum number of dimensions allowed for an array in C++?
c++, multidimensional-array
Solution
The standard recommends the implementations to accept at least 256 (ISO 14882, B.2), but they may support less or more:
The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.
[…]
— Pointer, array, and function declarators (in any combination) modifying an arithmetic, structure, union, or incomplete type in a declaration [256].
It's the same in both C++03 and C++11.
Problem
You can declare a very simple array with 10 elements and use it that way : ``` int myArray[10]; myArray[4] = 3; std::cout << myArray[4]; ``` Or declare a 2d array with 10x100 elements as `int myArray[10][100];` Even create more complicated 3-d arrays with `int myArray[30][50][70];` I can even go as far as writing : ``` int complexArray[4][10][8][11][20][3]; complexArray[3][9][5][10][15][3] = 5; std::cout << complexArray[3][9][5][10][15][3]; ``` So, what is the maximum number of dimensions that you can use when declaring an array?