10.10. Case Study: Array Class

We discussed built-in arrays in Chapter 8. Pointer-based arrays have many problems, including:

• A program can easily “walk off” either end of a built-in array, because C++ does not check whether subscripts fall outside the range of the array (though you can still do this explicitly).

• Built-in arrays of size n must number their elements 0, ..., n – 1; alternate subscript ranges are not allowed.

• An entire built-in array cannot be input or output at once; each element must be read or written individually (unless the array is a null-terminated C string).

• Two built-in arrays cannot be meaningfully compared with equality or relational operators (because the array names are simply pointers to where the arrays begin ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.