在 vc++ 2008 express 中尝试 wcout wstring 时,我收到一条相当奇怪的错误消息:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)
如果我理解正确,它会报告 wcout 不接受 wstring?我请人在 linux 下编译这段代码,它运行良好。我还在另一台装有 vc++ 2008 express 的计算机上尝试了相同的代码,但仍然失败。 vc++ 2008 中 std 的一个已知问题?
#include <iostream>
int main()
{
std::wstring unicode_test = L"Unicode var";
std::wcout << L"Unicode non-var" << std::endl;
std::wcout << unicode_test << std::endl; //<-- This line fails!
}
我正在使用 vc++ 2008 express sp1 以及 KB948127 之前的所有更新。我知道控制台需要更改代码页,但这甚至没有编译。谢谢。
最佳答案
您需要#include <string>
.我不确定标准怎么说,但我很确定 <iostream>
不需要导出所有 <string>
,如果有的话。
[编辑]至少 cplusplus.com甚至没有列出 string
作为 <iostream>
中声明的类型.不,这不是标准,我知道...[/edit]
关于unicode - 尝试使用 std::wcout << wstring-var 时出现错误 C2679; vc++ 2008 express ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1439012/