c++ - 开发 C++ "to_string is not a member of std"错误

标签 c++ string

我在 Dev-C++ 中将 int 转换为 string 时遇到问题。

我有正确的 #include,但我仍然得到:

[Error] 'to_string' is not a member of 'std'

const int MAX_KOSZT = 999999;    
string convert(int val) {
  if (val == MAX_KOSZT) 
  {
    return "--";
  } 
  else {
    if (val < 10) {
      return "0" + std::to_string(val);
    } 
    else {
      return std::to_string(val);
    }
  }
}

void getCout()
{
  cout << convert(sciana) << "," << convert(chodnik);
}

最佳答案

编译器默认不提供 C++11 功能。

我怀疑您需要在编译器设置中将语言标准更改为 ISOC++11 或 GNUC++11。

如果您正在使用一个项目,您将在项目选项中找到它(右键单击该项目)。如果没有,我想您会在“工具”菜单中找到它。

您需要的选项看起来像这样 http://www.cplusplus.com/doc/tutorial/introduction/devcpp/devcpp2.png

关于c++ - 开发 C++ "to_string is not a member of std"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35874215/

相关文章:

c++ - 具有虚拟和非虚拟析构函数的 delete 运算符的不同行为

Javascript:使用 new 创建字符串是否意味着我需要稍后发布它?

java - 匹配器查找无限循环

html - 将字符串从 html 转换为列表

java - 替换所有特殊字符、数字和字母

python - 评估 python 中字符串中子字符串存在的最佳性能方法?

c++ - 使用 boost.xpressive 重复变量 min/max

c++ - Hook 和取消 Hook 一个文件 DLL

c++ - 从嵌套在模板中的类派生时的编译问题

c++ - 使用 std::chrono::duration 跟踪超时