Summary
Pointers can be a powerful technique for managing objects on the heap. They bring risks of memory leaks and stray pointers; but, if you are careful, they are safe and effective to use in your programs.
You can declare pointers to be constant, and enlist the compiler in helping you find those places in which you use your pointers in ways you had not intended. The this pointer is a hidden parameter to every member method and provides a pointer to the object itself. Const pointers allow you to refer to an object's address without allowing you to use the pointer to modify the object. Const member functions are member functions that promise they will not alter the state of the object. Const member functions have a constant this pointer.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access