base operand of `->' has non-pointer type

funnyone 2010-09-14 06:40:30
32 G:\代码\成对的字符串.cpp base operand of `->' has non-pointer type `std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > >'

for(multimap<char,map<int,int> >::iterator itor=test.begin();itor!=test.end();++itor)
if(itor->second->first==1) //这一行
++itor->second->second; //每一次迭代增加每一个距离
...全文
2748 9 打赏 收藏 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
里面的那个map,也必须用iterator,那样才有->first
pengzhixi 2010-09-14
  • 打赏
  • 举报
回复
map可没有->first这样的操作。
  • 打赏
  • 举报
回复


multimap<char,vector<int> > s;
vector<int> ivc;

s.push_back(make_pare<'c', ivc>)
funnyone 2010-09-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 regainworld 的回复:]

->改成.试试
[/Quote]

不对,已经不能改啦,
键值不变也没意义啦
你说
multimap<char,vector<int> >如何添加值
regainworld 2010-09-14
  • 打赏
  • 举报
回复
->改成.试试
funnyone 2010-09-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 mstlq 的回复:]

最简单的类比……
C/C++ code

map<int, int> > test;
if (test->first==1) ++test->second;

楼主知道上面错在哪里吗?

请翻教材去吧……
[/Quote]

你说
multimap<char,vector<int> >如何添加值

刚才忽然想到map键值不能改变
mstlq 2010-09-14
  • 打赏
  • 举报
回复
最简单的类比……

map<int, int> > test;
if (test->first==1) ++test->second;

楼主知道上面错在哪里吗?

请翻教材去吧……
funnyone 2010-09-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mstlq 的回复:]

itor->second是一个map
[/Quote]

我知道,那贼摸弄那个,map中的int呢?
mstlq 2010-09-14
  • 打赏
  • 举报
回复
itor->second是一个map

65,213

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧