作者supercygnus (......)
看板Programming
标题Re: [问题] 两题C++的问题.样板与结构
时间Tue Apr 5 11:04:19 2011
第一题的程式码
#include <iostream>
#include <cstdlib>
using namespace std;
template <class T>
void swap1(T& x, T& y)
{
T temp;
temp=x;
x=y;
y=temp;
}
int main(void)
{
int a=5,b=8;
double c=1.25,d=6.64;
swap1(a,b);
swap1(c,d);
cout<<a<<" "<<b<<endl;
cout<<c<<" "<<d<<endl;
system("pause");
return 0;
}
函数名称竟然不能用swap会有错误,是编译器有内定了? 害我卡了好久
改成swap1竟然就可以了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.105.145
1F:推 jtmh:有错误,那错让讯息是?218.175.150.249 04/05 11:52
2F:→ yauhh:如果有内定,错误讯息应该会讲ambiguous 61.231.64.117 04/05 12:09