October 2004
Intermediate to advanced
624 pages
16h 2m
English
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 ...