C++ STL 中map的value_comp问题。 10

#include<iostream>#include<cstdlib>#include<string>#include<map>#include"print.h"usin... #include <iostream>
#include <cstdlib>
#include <string>
#include <map>
#include "print.h"
using namespace std;
int main()
{
map<int,string> t;
t[1] = "January";
t[2] = "February";
t[3] = "March";
t[4] = "April";
t[5] = "May";
t[6] = "June";
t[7] = "July";
t[8] = "August";
t[9] = "September";
t[10] = "October";
t[11] = "November";
t[12] = "December";
string t1 = "July" , t2 = "May";
map<int,string>::key_compare mycomp = t.key_comp();
map<int,string>::value_compare myvcomp = t.value_comp();
cout << t.at(1) << endl;
out();
cout << boolalpha << mycomp(1,5) << endl;
cout << myvcomp(“Octorber”,"December") << endl;
//为什么这一句会出错呢???
out();
for(int i = 1;i < 13;i++)
cout << t[i] << endl;
cout << t[1] << endl;
return 0;
}
map.cpp:30:39: error: no match for call to '(std::map<int, std::basic_string<cha
r> >::value_compare) (const char [9], const char [9])'
cout << myvcomp("December","December") << endl;
^
In file included from d:\program\g++\lib\gcc\mingw32\4.8.1\include\c++\map:61:0,
from map.cpp:4:
d:\program\g++\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_map.h:114:13: note: ca
ndidate is:
class value_compare
^
展开
 我来答
IT孤鹜
2015-09-13 · TA获得超过4198个赞
知道大有可为答主
回答量:3960
采纳率:71%
帮助的人:3569万
展开全部
myvcomp("Octorber","December");
Octorber 的引号,你用的是中文输入法的,编译器识别不了
追问
不是这个问题   我补充了错误信息 麻烦看一下
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式