template<class T> void swap(T& a, T& b)
{
T t = a;
a = b;
b = t;
}
template<> void swap(char* c, char* d)
{
char* ptmp = new char[strlen(c) + 1];
strcpy(ptmp, c);
strcpy(c, d);
strcpy(d, ptmp);
}
{
T t = a;
a = b;
b = t;
}
template<> void swap(char* c, char* d)
{
char* ptmp = new char[strlen(c) + 1];
strcpy(ptmp, c);
strcpy(c, d);
strcpy(d, ptmp);
}
解决方案
10
用 char*&
30
你模板里面有引用啊