Caffeinated Coder
Book an appointment
Lesson 08 · Memory

References

A C++ reference is a second name for an object that already exists: it makes no new box of memory. Follow a ten-line program as int& ref = score puts a second name tag on score's box, a write through ref changes score, and a reference parameter lets a function double the caller's variable. Then drop the & to see pass by value make a copy, and meet const& for reading big values without copying them.

11 min9 steps5 questionsIntermediate
Fig 8 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.