Lecture overview -- Keyboard shortcut: 'u'  Previous page: References -- Keyboard shortcut: 'p'  Next page: References - Examples -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 16 : 42
Notes about C++
Basic facilities
Rules for references

  int k = 3;
  double a = 5.0;
  double &d = a;
  void f(int &i, double &d);
  f(k,a);

C++ References.

  • A reference must be initialized when declared

  • A reference is constant by nature

    • Once established the reference can never be set to reference something else

  • No operator operates on a reference as such - only the object referenced

  • Pointers to references and arrays of references do not exist

    • But references to pointers and references to array can exists

"The absence of const in a declaration of a reference argument is taken as a statement of intent to modify the variable"

  • The C++ Programming Language: Page 146