C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c wcout std :: map value大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个名为’prompts’的std :: map,声明如下:

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

它存储int’key’和wString’value’对.如果我这样做:

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)

我需要做什么才能从地图返回的wString值用wcout打印?某种演员?要么…?

解决方法

在第一行,你缺少一个std ::

std :: map< const int,std :: wString,std :: less< int&gt ;,std :: allocator< std :: pair< const int,std :: wString> >>提示;

你应该写std :: wcout而不是wcout.

我只是尝试了这个代码,它编译.

#include <map>
#include <iostream>
#include <String>

int main()
{
    std::map<const int,std::wString,std::wString> >> prompts;
    std::wcout << prompts[1];
    return 0;
}

大佬总结

以上是大佬教程为你收集整理的c wcout std :: map value全部内容,希望文章能够帮你解决c wcout std :: map value所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。