void f(int **a); // function expecting 2D array
// ...
int nx, ny;
std::cin >> nx >> ny; // read dimensions
int **array; // pointer to first element of
// the 'secondary' array
array = new int *[nx]; // create memory for nx pointers to int
array[0] = new int[nx*ny];
// nx*ny elements in the entire array,
// array[0] is a pointer to the first
// ``row'' of ny elements and equals
// the pointer to the beginning of the
// entire array
for(int i=1; i < ny; i++ )
array[i] = array[0] + i * ny;
// points to i'th segment of ny integers
if ( nx > 23 && ny > 10 )
array[23][10] = 17; // ok if 23 < nx and 10 < ny
f( array ); // OK, array is int **, but subscripting
// behaves as if it were a 2D field