References

A references is a new type of variables that C++ provides.

References are primarily used to pass parameters to functions and return values back from functions

The code below illustrates how to declare a reference, and how a reference works:

int x;               // declare an integer x
int  &r = x ;     // declare r as a reference to an int, and initialize it to x (i.e., r is another name, or alias, for x)
x = 3;             // assign the value 3 to x
r++;               //  increment r. This will also increment x. So now x=4

In C, an equivalent code could be:

int x; // declare an integer x
int* const p = &x; // declare p as a constant pointer to an int, and initialize it to the address of x
x = 3; // assign the value 3 to x
(*p)++; // increment *p (i.e. increment what p points to). This will also increment x. So now x=4

In the C example, we can change what p points to, but not p itself (since p is a constant pointer).