|
A reference variable is an alias for another variable. All reference variables must be initialized when declared. From then on, any changes made to the referenced variable will be made to the aliased variable. Reference variables are particularly important when passing variables to functions; this topic will be covered in more detail later, but here’s an example:
int x = 10; int& y = x; // declare y as reference to x. y = 4; // Changes the value of x to 4.
|