Skip to Content
Imperfect C++ Practical Solutions for Real-Life Programming
book

Imperfect C++ Practical Solutions for Real-Life Programming

by Matthew Wilson
October 2004
Intermediate to advanced
624 pages
16h 2m
English
Addison-Wesley Professional
Content preview from Imperfect C++ Practical Solutions for Real-Life Programming

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical C++ Metaprogramming

Practical C++ Metaprogramming

Edouard Alligand, Joel Falcou

Publisher Resources

ISBN: 0321228774Purchase book