这是我试图编译的代码,从某个地方的另一个论坛得到它。
// 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;
}
我收到错误:'to_string'不是'std'的成员
我已经在其他论坛中阅读了选择标志“让g ++遵循c ++ 11 ISO语言标准[-std = c ++ 11]”并且我拥有它仍然不起作用。
任何帮助将不胜感激
我正在使用GNU GCC编译器和代码:: Blocks 12.11
发布于 2018-12-12 13:45:08
处理此错误的最简单方法是:
double piValue = 3.1415;
char piBuffer[8];
sprintf(piBuffer, "%f", piValue);
string pi(piBuffer);
https://stackoverflow.com/questions/-100003059
复制相似问题