8.12 Wrap-Up
In this chapter we provided a detailed introduction to pointers—variables that contain memory addresses as their values. We began by demonstrating how to declare and initialize pointers. You saw how to use the address operator (&
) to assign the address of a variable to a pointer and the indirection operator (*
) to access the data stored in the variable indirectly referenced by a pointer. We discussed passing arguments by reference using pointer arguments.
We discussed how to declare and use built-in arrays, which C++ inherited from the C programming language. You learned how to use const
with pointers to enforce the principle of least privilege. We demonstrated using nonconstant pointers to nonconstant data, nonconstant pointers ...
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.