Previous section   Next section

Imperfect C++ Practical Solutions for Real-Life Programming
By Matthew Wilson
Table of Contents
Part Three.  Language Concerns


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 sizes, array/pointer duality, and the uniquely C++ problem of passing pointers to arrays of inherited types.


      Previous section   Next section