Hour 12. Creating References

What Is a Reference?

In the past 2 hours, you learned how to use pointers to manipulate objects on the heap and how to refer to those objects indirectly. References, the topic of this hour, give you almost all the power of pointers but with a much easier syntax.

A reference is an alias. When you create a reference, you initialize it with the name of another object, the target. From that moment on, the reference acts as an alternative name for the target, and anything you do ...

Get Sams Teach Yourself C++ in 24 Hours, fifth edition 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.