August 2012
Intermediate to advanced
976 pages
30h 17m
English
A type alias (§ 2.5.1, p. 67) can make it easier to read, write, and understand pointers to multidimensional arrays. For example:
using int_array = int[4]; // new style type alias declaration; see § 2.5.1 (p. 68)typedef int int_array[4]; // equivalent typedef declaration; § 2.5.1 (p. 67)// print the value of each element in ia, with each inner array on its own linefor (int_array *p = ia; p != ia + 3; ++p) { for (int *q = *p; q != *p + 4; ++q) cout << *q << ' '; cout << endl;}
Here we start by defining int_array as a name for the type “array of four ints.” We use that type name to define our loop control variable in the outer for loop.
Exercises Section 3.6
Exercise 3.43: ...
Read now
Unlock full access