Summary

This chapter deals with rather complex material. You looked at several uses of pointers in C++. The first one was to use pointers to point to ordinary variables allocated on the stack and to provide an alternative technique of accessing these variables through aliasing. With the exception of passing parameters by pointer (which I will discuss in the next chapter) this technique is useless. However, some programmers believe that this technique makes their code easier to understand. Make sure you are ready to deal with this kind of pointer manipulation in legacy code.

The second use of pointers is allocating individual variables on the stack rather than on the heap. The heap variables do not have names, and the use of pointers provides ...

Get Core C++ A Software Engineering Approach 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.