I am trying to use c++ template generics with a void function,
The code:
#include <iostream>
using namespace std;
template <typename T>
inline void swap(T& x, T& y)
{
T temp = x;
x = y;
y = temp;
}
int main()
{
cout << "Swapper!" << endl;
int x, y;
cin >> x >> y;
swap(x, y);
cout << x << y;
cin.get();
return 0;
}
But it gives an error:
call of overloaded swap() is ambiguous
How do I remove this error?