Multidimensional Arrays

An array can be thought of as a row of data. You can imagine a grid of data, with rows and columns. This is a two-dimensional array of data, with one dimension representing each row and the second dimension representing each column. A three-dimensional array would be a cube, with one dimension representing width, a second dimension representing height, and a third dimension representing depth. You can even have arrays of more than three dimensions, though they are harder to imagine as objects in space.

When you declare arrays, each dimension is represented as a subscript in the array. Therefore, a two-dimensional array has two subscripts, a three-dimensional array has three subscripts, and so on. Arrays can have any number ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition 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.