The C++ Data Types
are defined using: type &object_name; // object_name can become an alternative
name or an alias for objects of the particular type
int I = 1, &r = I; // I and r refer to the same integer type object
The use of references is often found in specifying the types of arguments and
return values for functions and overloaded operators. The following examples
show the use of references as types of arguments or and return values of functions.
Example 1: void f(double &A) { A += 3.14;} // f() updates the value of an object
//of type double referenced by A, and does not return any values
double d = 0.0; // declare and initialize object d
f(d); // call f and pass it the reference of d
//Compare the above with code using a pointer instead of a reference