1

为什么这不能在 gcc 上编译?

#include <iostream>
#include <string>
 
int main() {
 
    double f = 23.43;    
    std::wstring f_str = std::to_wstring(f);
    std::wcout << f_str << std::endl;
 
    return 0;
}

错误:

prog.cpp:在函数'int main()'中:

prog.cpp:6:26: 错误:“to_wstring”不是“std”的成员</p>

例子

4

2 回答 2

5

std::to_wstring()在 C++11 中添加。您在 ideone 上的答案中的链接使用 C++11 编译器:

语言:C++ (gcc-4.7.2)

它编译得很好: http: //ideone.com/UO2FQM

语言:C++0x (gcc-4.7.2)

于 2013-02-01T13:28:53.333 回答
1

如果您在 IDEONE 中选择 C++0x 而不是 C++,则您的程序将编译,因为它是 C++11 功能。

于 2013-02-01T13:29:33.610 回答