Let consider declaration
int test[5][5][5];
step by step.
At first consider declaration like
int test[5];
test has 5 elements of type int
.
Now consider
int test[5][5];
It declares an array of 5 elements of the preceding type int[5]
. So as each element of the array in turn an array and contains 5 elements then the total number of elements of type int contained in test is equal to 5 * 5 that is 25.
Now let's return to declaration
int test[5][5][5];
It defines an array elements of which has type int[5][5]
. Each element contains 25 objects of type int
. The array has 5 such elements. So in total it contains 5 * 25 objects of type int
that is 125 such objects.
So array
int test[5][5][5];
has 5 elements of type int[5][5]
array
int test[5][5];
has 5 elements of type int[5]
and array
int test[5];
has 5 elements of type int
.
In C++ a multidimensional array is an array elements of which are in turn arrays (not pointers).