#include<iostream>
using namespace std;
template <class T>
void myswap(T & tmp1, T & tmp2)
{
T temp;
temp = tmp1;
tmp1 = tmp2;
tmp2 = temp;
return;
}
main()
{
int x = 1;
int y = 20;
double p = 10.9, q = 23.36;
char s = 'o', t = 'u';
myswap(x, y);
cout << "x=" << x << "and y=" << y << endl;
myswap(p, q);
cout << "p=" << p<< "and q=" << q << endl;
myswap(s, t);
cout << "s=" << s << "and t=" << t << endl;
return 0;
}
我使用Visual Studio2013。运行此代码时,编译器会向我显示消息“错误:缺少类型说明符-假定为int。C++不支持默认int”。
最佳答案
函数main必须具有返回类型int,即
int main()
关于c++ - 错误1错误C4430 : missing type specifier - int assumed. Note: C++ does not support default-int,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20250792/