i create a template but get error.
the template and main (this code in one cpp file):
#include <iostream>
using namespace std;
template<class T> 
void swap(T& x, T& y);
template<class T> 
void swap(T& x, T& y){
    T temp = x;
    x = y;
    y = temp;
}
int main(){
int n1 = 10, n2 = 5;
cout << "number before swap: num1= " << n1 << " num2= " << n2 << endl;
swap(n1, n2);//compilation error
cout << "number after swap: num1= " << n1 << " num2= " << n2 << endl;
system("pause");
return 0;
}
error:
Error   1   error C2668: 'std::swap' : ambiguous call to overloaded function    
c:\projects\template\main.cpp   42  1   Template
2   IntelliSense: more than one instance of overloaded function "swap" 
matches the argument list:
        function template "void swap(T &x, T &y)"
        function template "void std::swap(_Ty &, _Ty &)"
        argument types are: (int, int)  c:\Projects\Template\main.cpp   43  
2   Template
why i get error i don't understand because all look fine. thank's for the help.
thank's.
 
     
     
     
    