首页 > to_string不存在问题

to_string不存在问题

提示:

D:C programLightOjmain.cpp|8|error: 'to_string' is not a member of
'std'|

这是代码:

// to_string example
#include <iostream>   // std::cout
#include <string>     // std::string, std::to_string
int main ()
{
  std::string pi = "pi is " + std::to_string(3.1415926);
  std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";
  std::cout << pi << '\n';
  std::cout << perfect << '\n';
  return 0;
}

IDE是code::blocks,请问这个是为什么呢?


检查你的编译器版本,看是否支持c++11特性,是否支持这个新的标准库函数


你在codeblock里面设置成按c++11编译试试.设置方法http://www.360doc.com/content...。。
如果还不行,就应该是楼上说的,编译器不支持吧

【热门文章】
【热门文章】