Chapter 33. Multidimensional Arrays
As we saw in section 14.7, C and C++ do not support multidimensional arrays of dynamic size, except where all but the most significant dimension is of constant size. In other words, you can do the following:
void f(int x) { new byte_t[x]; }
but not:
void f(int x, int y, int z)
{
new byte_t[x][y][z]; // Error
}
Creating a multidimensional array can only be in this form:
const size_t Y = 10;
const size_t Z = Y * 2;
void f(int x)
{
new byte_t[x][Y][Z];
}
This can be quite a restriction. For example, a couple of years ago I was working on a multimedia product user interface where the layout of the interface was dynamically retrieved from a central server over the Internet. The layout could be any possible combination ...
Get Imperfect C++ Practical Solutions for Real-Life Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.