8.1 Introduction

This chapter discusses pointers—one of C++’s most powerful, yet challenging to use, capabilities. We’ll help you determine when it’s appropriate to use pointers, and show you how to use them correctly and responsibly.

In Chapter 6, we saw that references can be used to perform pass-by-reference. Pointers also enable pass-by-reference and can be used to create and manipulate dynamic data structures that can grow and shrink, such as linked lists, queues, stacks and trees. This chapter explains basic pointer concepts. Chapter 19 presents examples of creating and using pointer-based dynamic data structures.

We also show the intimate relationship among built-in arrays and pointers. C++ inherited built-in arrays from the C programming ...

Get C++ How to Program, 10/e 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.