Chapter 14. Arrays and Pointers

An array is “a fixed collection of same-type data . . . [logically] stored contiguously and . . . accessible by an index” [Sedg1998a], and is one of the fundamental data structures [Knut1997]. While most languages have arrays, many modern ones do not have pointers because they are deemed too dangerous. Pointers allow direct access to the memory locations of the instances to which they point, but they can, and often do, lead to memory corruption. Nonetheless C and C++ provide pointers because they afford such power and opportunity for efficiency, in keeping with the “Spirit of C” (see Prologue).

In this chapter, we look at some issues where the language(s) leave something to be desired, including the issues of array ...

Get Imperfect C++ Practical Solutions for Real-Life Programming now with O’Reilly online learning.

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