Introduction to References
Swipe to show menu
A reference is simply another name for an existing variable. Instead of creating a new variable with its own memory, a reference points to the same memory location as the original variable. This means both names work with the same value.
reference.h
12int originalVariable = 42; int& referenceVariable = originalVariable;
So, when you use referenceVariable, you are actually working with originalVariable.
Advantages of Reference
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 9
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
SectionΒ 1. ChapterΒ 9