C++ TutorialLesson 22Free preview
C++ References
This lesson is part of C++ · All levels
Summary
This lesson is about references, which are aliases or other names for a variable that shares the same memory. Reference must be initialized when created and cannot be redirected to other variables. Because changes through reference directly alter the original data, this feature is often used on function parameters to avoid data copying.
Key points
- Reference declaration: type &name = original variable;.
- Reference is an alias, not a copy, so modifying it changes the original data.
- Reference must be initialized and cannot be directed to other variables.
- Reference is widely used as a parameter for a function to change its original value.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.