VC++2005使函数返回值为枚举变量或自定义类时编译器提示缺少类型说明符
代码:
#include "stdafx.h"
#include <iostream>
using namespace std;
enum ERR_CODE { SUCCESS, ERROR };
ERR_CODE Factor(int, int&, int&);
int _tmain(int argc, _TCHAR* argv[])
{
int number, squared, cubed;
ERR_CODE result;
cout << "Enmber a number (0 - 20): ";
cin >> number;
result = Factor(number, squared, cubed);
if (result == SUCCESS)
{
cout << "number: " << number << endl;
cout << "squared: " << squared << endl;
cout << "cubed: " << cubed << endl;
}
else
cout << "Error encountered!!" << endl;
char v;
cin >> v;
return 0;
}
ERR_COED Factor(int n, int &rSquared, int &rCubed)
{
if (n > 20)
return ERROR;
else
{
rSquared = n*n;
rCubed = n*n*n;
return SUCCESS;
}
}
编译器提示:error C2146: 语法错误 : 缺少“;”(在标识符“Factor”的前面)
缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
这是什么问题?