代码是正确的:
#include <iostream>
template <typename T>
void swap(T &a, T &b);
int main()
{
using namespace std;
int i = 10;
int j =20;
swap (i,j);
cout << i << endl;
cout << j << endl;
return 0;
}
template <typename T>
void swap(T &a, T &b)
{
T = temp;
temp = a;
a = b;
b = temp;
}