April 2024
Beginner
656 pages
23h 19m
English
Caveat emptor!
– Good advice
This chapter describes the lower-level notions of arrays and pointers. We consider the uses of pointers, such as array traversal and address arithmetic, and the problems arising from such use. We also present the widely used C-style string; that is, a zero-terminated array of chars. Pointers and arrays are key to the implementation of types that save us from error-prone uses of pointers, such as vector, string, span, not_null, unique_ptr, and shared_ptr. As an example, we show a few ways we can implement a function that determines whether a sequence of characters represents a palindrome.