previous | index | next

Reference Parameters

C++ introduced reference parameters, which: To indicate that a function parameter is to be a reference parameter, simply add an ampersand '&' to the parameter's type.

void swap(int& a, int& b) {
  int temp = a;
  a = b;
  b = temp;
}

Call by reference through reference parameters is not available in C or Java.


previous | index | next