No, if the second dimension is different it won't work. The best you can do is something like this:
struct arr {
int *p; // pointer to first element
int x, y, z; // array size
int &at(int i, int j, int k) {
return p[((i*y)+j)*z+k];
}
}
Or you can use your favorite multidimensional array library. C++ lacks built-in support for multidimensional arrays unless all but the first size is known at compile time, and C99 VLAs won't work in this situation. This is because C/C++ use the type of the array to figure out how big it is in each dimension (except the first dimension, which can be unspecified).