Chapter 4. Arrays and Pointers

CONTENTS

Section 4.1 Arrays 110

Section 4.2 Introducing Pointers 114

Section 4.3 C-Style Character Strings 130

Section 4.4 Multidimensioned Arrays 141

Chapter Summary 145

Defined Terms 145

The language defines two lower-level compound types—arrays and pointers—that are similar to vectors and iterators. Like a vector, an array holds a collection of objects of some type. Unlike vectors, arrays are fixed size; once an array is created, new elements cannot be added. Like iterators, pointers can be used to navigate among and examine the elements in an array.

Modern C++ programs should almost always use vectors and iterators in preference to the lower-level arrays and pointers. Well-designed programs use arrays and ...

Get C++ Primer, Fourth 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.