more-dimensional arrays
Let’s say it’s very similar when you use it. However, conceptually this is different. The C++ code declares “a vector of length 20 of pointers to a vector of int of length 30”. So “matrix” is a pointer to a pointer to int. There is no length/dimension checking done anywhere.
In Fortran, you can only get a “rectangular blob” of memory, that is, the above will always have 20*30 elements. In C++ you can (dynamically) construct arrays with “ragged” boundaries, where each row has a different number of columns.
matrix = new int *[20]; // a vector of length 20 of pointers to int
for (int j=0, jង j++) *matrix[j] = new int [30];
// do something… this is the same as matrix[20][30];
for (int j=0, jង j++) delete [] *matrix[j];
matrix = new int *[20]; // a vector of length 20 of pointers to int
for (int j=0, jង j++) matrix[j] = new int [j+10];
// do something… this is the same as matrix[20][30];
for (int j=0, jង j++) delete [] matrix[j];