首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >“numeric_limits”未在此范围内声明,没有用于调用“max()”的匹配函数

“numeric_limits”未在此范围内声明,没有用于调用“max()”的匹配函数
EN

Stack Overflow用户
提问于 2011-01-26 05:17:44
回答 2查看 43.3K关注 0票数 35

我在家里用xcode在mac上编译了这段代码,没有任何问题。我在学校用linux上的g++编译了它,我得到了这些错误:

numeric_limits‘不是std的成员

应为‘>’标记前的主表达式

对‘max()’的调用没有匹配的函数

代码语言:javascript
复制
#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

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4798936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档