A reference is an alternative name for an object.
A reference variable provides an alias name for a previously defined variable of
the same data type. No extra memory is allocated to the reference variable.
A reference declaration consists of a data_type, an ampersand (&), a reference
variable name equated to a variable name which is previously defined.
The general form of declaring a reference variable is:
data_type &ref_var = variable_name;
Where data_type is any valid C++ data type, ref_var is the name of the reference
variable that will point to variable denoted by variable_name.
Let us consider an example:
int total;
int &sum = total;
sum = 100;
cout << total; // It prints 100
In the above code both variables total and sum refer to the same data object in the
memory, thus it prints the same value.