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

In this hour, you learned what references are and how they compare to pointers. You saw that references must be initialized to refer to an existing object, and cannot be reassigned to refer to anything else. Any action taken on a reference is, in fact, taken on the reference's target object. Proof of this is that taking the address of a reference returns the address of the target.

In this hour you also examined null pointers and null references, and learned why null pointers are useful, but null references are disastrous. You went on to learn about how pass by reference semantics differ from pass by value. Finally, you saw how to use references to return multiple values from function calls.

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