我在家里用xcode在mac上编译了这段代码,没有任何问题。我在学校用linux上的g++编译了它,我得到了这些错误:
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
https://stackoverflow.com/questions/4798936
复制相似问题