// Dit programma test drie varianten van het doorgeven van parameters
// aan een Wissel-functie (zie ook blz. 8 van het dictaat).

#include <iostream>
using namespace std;

//********************************************************************

void Schrijf (int a, int b)
{
  cout << " is a = " << a << " en b = " << b << ".\n";

}  // Schrijf

//********************************************************************

void Wissel1 (int a, int b)
{ int temp;
  // N.B.: in verschillende functies mogen dezelfde variabele namen voorkomen
  //   (in dit geval de parameters `a' en `b' en de locale variabele `temp').
  //   In een functie is alleen (de waarde van) de variabele bekend die in
  //   die functie is gedeclareerd.

  temp = a;
  a = b;
  b = temp;
  cout << "Aan het eind van Wissel1";
  Schrijf (a, b);

}  // Wissel1

//********************************************************************

void Wissel2 (int &a, int b)
{ int temp;

  temp = a;
  a = b;
  b = temp;
  cout << "Aan het eind van Wissel2";
  Schrijf (a, b);

}  // Wissel2

//********************************************************************

void Wissel3 (int &a, int &b)
{ int temp;

  temp = a;
  a = b;
  b = temp;
  cout << "Aan het eind van Wissel3";
  Schrijf (a, b);

}  // Wissel3

//********************************************************************

int main ()
{ int Origa, Origb,  // voor invoer gebruiker; wordt nooit gewijzigd
      a, b;

  cout << endl;
  cout << "Geef twee gehele getallen : ";
  cin >> Origa >> Origb;

  cout << endl;
  cout << "We gaan nu Wissel1 testen.\n";
  a = Origa;
  b = Origb;
  cout << "Van tevoren";
  Schrijf (a, b);
  Wissel1 (a, b);
  cout << "Na afloop";
  Schrijf (a, b);

  cout << endl;
  cout << "We gaan nu Wissel2 testen.\n";
  a = Origa;
  b = Origb;
  cout << "Van tevoren";
  Schrijf (a, b);
  Wissel2 (a, b);
  cout << "Na afloop";
  Schrijf (a, b);

  cout << endl;
  cout << "We gaan nu Wissel3 testen.\n";
  a = Origa;
  b = Origb;
  cout << "Van tevoren";
  Schrijf (a, b);
  Wissel3 (a, b);
  cout << "Na afloop";
  Schrijf (a, b);

  return 0;

}

