17
我编译此代码在家里在我的Mac W/Xcode和没有问题。我编译它在使用g ++在Linux学校和我得到这些错误:'numeric_limits'没有在此范围内声明,没有匹配的函数调用'max()'
:“numeric_limits”不是STD
的成员:预期前主表达式“>”令牌
:用于调用没有匹配的功能'max()'
#include <iostream>
#include <cstdlib>
using namespace std;
int GetIntegerInput(int lower, int upper)
{
int integer = -1;
do
{
cin >> integer;
cin.clear();
cin.ignore(std::numeric_limits<streamsize>::max(), '\n'); //errors here
}while (integer < lower || integer > upper);
return integer;
}
我打扰了,也许我必须包括一个额外的标题。如果我带走的std ::它只是给了我一个类似的错误
“numeric_limits”在此范围
当您阅读`numeric_limits`的文档以了解如何使用它时,是不是告诉您它在哪个头部? – 2011-01-25 22:33:11
是的,但那是前一阵子,然后我刚刚复制粘贴从我的其他项目代码没有意识到。 – 2011-01-27 00:44:45