|
#include <iostream>
using namespace std;
template<typename T>
void swap(T &a,T &b);
int main()
{
int i=10;
int j=20;
cout<<"i="<<i<<",j="<<j<<endl
<<"after swap:"<<endl;
swap(i,j);
cout<<"i="<<i<<",j="<<j<<endl;
return 0;
}
template<typename T>
void swap(T &a,T &b)
{
T temp;
temp=a;
a=b;
b=temp;
}
errors:
E:\VC\10-31\aa.cpp(13) : error C2667: 'swap' : none of 2 overload have a best conversion
E:\VC\10-31\aa.cpp(13) : error C2668: 'swap' : ambiguous call to overloaded function |
|