【发布时间】:2013-01-19 18:11:33
【问题描述】:
#include <iostream>
#include <string>
using namespace std;
int main()
{
wcout << L"Hello"; // OK.
wcout << wstring(L"Hello"); // OK.
wcout << "Hello"; // OK. Why?
wcout << string("Hello"); // Error. Why?
}
为什么std::wcout 接受窄字符串文字作为其参数,但不接受窄字符串对象?
【问题讨论】:
-
error: no match for 'operator<<' in 'std::wcout << std::basic_string<char>(((const char*)"Hello"), (*(const std::allocator<char>*)(& std::allocator<char>())))'? -
+1 我也对这个 IOStream 的怪异感到困惑。
-
为什么?因为石冷是这么说的!这就是为什么
标签: string encoding iostream c++