Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'                swap-similar-cpp.cc - C++ Preview: A similar C++ program with a swap function - uses references.Lecture 1 - slide 28 : 34
Program 2

#include <iostream>
using namespace std;

void swap_doubles_references(double &d1, double &d2){
  double temp;
  temp = d1;
  d1 = d2;
  d2 = temp;
}

int main(){
  double e, f;

  e = 5.0, f = 7.0;
  cout << e << " " << f << endl;   // 5 7
  swap_doubles_references(e, f);  
  cout << e << " " << f << endl;   // 7 5

  return 0;
}