3.6. Multidimensional Arrays
Strictly speaking, there are no multidimensional arrays in C++. What are commonly referred to as multidimensional arrays are actually arrays of arrays. It can be helpful to keep this fact in mind when you use what appears to be a multidimensional array.
Exercise 3.41: Write a program to initialize a vector
from an array of int
s.
Exercise 3.42: Write a program to copy a vector
of int
s into an array of int
s.
We define an array whose elements are arrays by providing two dimensions: the dimension of the array itself and the dimension of its elements:
int ia[3][4]; // array of size 3; each element ...
Get C++ Primer, Fifth 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.