Not quite correct.
Your array p has 3 elements where each element is an array of 4 int. The
new operator returns the address of element 0 of p, which is p[0]. Since the name of an array is the
address of element 0, p[0] is the address of an array of 4 int:
- int (*p)[4];
-
p = new int[3][4];
-
cout<< p[0][0]; //element 0 of p[0]
Also remember that all you have is the address of these arrays. There's no way to know how many elements. You will need to keep track of ths using a variable which you provide to all functions that you provide the array address:
- const int numrows = 3;
-
const int numcols = 4;
-
int (*p)[numcols];
-
-
p = new int[numrows][numcols];
-
MyFunction(p, numrows, numcols);
-
etc...