O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required