/**
 * swap.cpp       
 * 19-mar-2007/sklar
 *
 * demonstrates the use of functions that use reference parameters 
 * see chapter 5 in the jones/harrow textbook
 *
 */

#include <iostream>
using namespace std;


// function prototypes:
void swap( int &a, int &b );
void notswap( int a, int b );


// main program
int main() {
  int x = 5;
  int y = 7;
  
  cout << "before swap: x=" << x << " y=" << y << endl;
  swap( x, y );
  cout << "after swap: x=" << x << " y=" << y << endl;
} // end of main()


// declare function swap(), using reference parameters
// this one works!
void swap( int &a, int &b ) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
  return;
} // end of swap()


// declare function notswap()
// this one doesn't work!
void notswap( int a, int b ) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
  return;
} // end of notswap()
