#include <iostream>
using namespace std;
template <class Any>
void swap(Any &a, Any &b)
{
Any temp;
temp=a;
a=b;
b=temp;
}
int main()
{
int i=10;
int j=20;
cout << "i, j=" << i << ", " << j << ".\n";
cout << "Using compiler-generated int swapper: \n";
swap(i,j);
cout << "Now i,j=" << i << ". " << j << ".\n";
double x=24.5;
double y=81.7;
cout << "x, y=" << x << ", " << y << ".\n";
cout << "Using compiler-generated int swapper: \n";
swap(x,y);
cout << "Now x,y=" << x << ". " << y << ".\n";
return 0;
}
定义的模板也没什么问题
可调用的时候就报错
万思不解
我刚刚学
真诚感谢大侠们帮小弟看看
[此贴子已经被作者于2007-9-14 9:22:11编辑过]

for(int i=0;i<无穷大;i++){我问牛鬼蛇神:我这样快乐好???答曰:你不快乐吗??}