I have learnt to declare a dynamic 2D array using a pointer as such. However I was told this does not create a contiguous 2D array.
int **p;
p = new int*[M];
for (int i = 0; i < M; ++i) {
p[i] = new int[N]; }
What is the way to modify the code to create a dynamic pointer to a contiguous 2D array?