I am getting an error "ambiguous call to overloaded function" . Can someone please explain why?
#include <iostream>
#include <string>
using namespace std;
template<typename T>
void swap(T &v1, T &v2)
{
T temp = v1;
v1 = v2;
v2 = temp;
}
int main()
{
int v1 = 1;
int v2 = 2;
swap(v1, v2);
return 0;
}
Because there's already a swap function in the std namespace.