2011-10-30 12 views
4

が、私はこのように宣言されている「プロンプト」と呼ばれるのstd ::マップがあります。C++ wcoutのstd ::マップ値

std::map<const int, wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts; 

をし、それがint型「キー」とwstringの「価値」のペアを格納します。

wcout << prompts[interpreter->get_state()]; 

コンパイラ(VC10)文句

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion) 

私はwcoutで印刷するマップから返されwstringの値を取得するために行う必要がありません:私はこれを行う場合は?ある種のキャスト?または...?最初の行で

答えて

1

、あなたがstd::

std::map<const int,のstd ::wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts;

が欠落しているあなたはstd::wcoutの代わりwcoutを記述する必要があります。

私はこのコードを試したところ、コンパイルしました。

#include <map> 
#include <iostream> 
#include <string> 

int main() 
{ 
    std::map<const int, std::wstring, std::less<int>, std::allocator<std::pair<const int, std::wstring> >> prompts; 
    std::wcout << prompts[1]; 
    return 0; 
} 
+0

はい、私はまた私の部分のいずれか....愚かな過ちを助けていませんでしたの代わりを含めた...右です。助けてくれてありがとう... – Mossen

+1

私はあなたの言語を非難したいと思います。 – cdiggins

関連する問題