1.16. Reference Variables

[ fromfile: references.xml id: references ]

  int n;
  int& rn = n;
  1. The address-of operator applies to an object and returns its address. Hence, it appears only on the right side of an assignment or in an initializing expression for a pointer variable.

  2. In connection with references, the ampersand is used only in the declaration of a reference. Hence, it appears only between the type name and the reference name as it is declared.

[Note]Note

For reference declarations, we recommend placing the ampersand immediately to the right of the type name:

 Type& ref(initLval);