#include <iostream>
using namespace std;
template<typename T>
void swapNum(T &a,T &b)
{
T temp = a;
a = b;
b = temp;
}
int main(void)
{
int x = 10;
int y = 20;
swapNum<int>(x,y);
cout << "x = " << x << endl;
cout << "y = " << y << endl;
return 0;
}
using namespace std;
template<typename T>
void swapNum(T &a,T &b)
{
T temp = a;
a = b;
b = temp;
}
int main(void)
{
int x = 10;
int y = 20;
swapNum<int>(x,y);
cout << "x = " << x << endl;
cout << "y = " << y << endl;
return 0;
}
最新回答 / z741092665
为什么不将try{...} catch{...} 放在main()函数里,这个接受异常的函数为什么不定义在类外,在main()外定义难道不好吗?否则你在类内的接受异常的函数里还要调用运算符重载的函数多乱呀。
2017-04-29