#include<iostream>
template <typename T>
void Swap(T &a, T &b);
int main(void)
{
using std::cout;
int i=10, j=20;
cout << "i,j = " << i << ", " << j << ".
";
cout << "Using compiler-generated int swapper:
";
Swap(i,j);
cout << "Now i, j = " << i << ", " << j << ".
";
double x=24.5, y=81.7;
cout << "x, y = " << x << ". " << y << ".
";
cout << "Using compiler-generated int swapper:
";
Swap(x,y);
cout << "Now x, y = " << x << ", " << y << ".
";
return 0;
}
template <typename T>
void Swap(T &a, T &b)
{
T temp;
temp = a;
a = b;
b = temp;
}