【发布时间】:2010-11-07 05:37:40
【问题描述】:
我有以下两张地图:
map< string, list < string > > map1;
map< string, list < string > > map2;
我用以下内容填充了map1:
1. kiran; c:\pf\kiran.mdf, c:\pf\kiran.ldf
2. test; c:\pf\test.mdf, c:\pf\test.mdf
然后我将map1的内容复制到map2中,如下:
map2 = map1;
然后我再次用以下新内容填充map1:
1. temp; c:\pf\test.mdf, c:\pf\test.ldf
2. model; c:\model\model.mdf, c:\pf\model.ldf
现在我必须将此内容附加到map2。我不能使用map2 = map1;,因为这会覆盖map2 中的现有内容。那么,我该怎么做呢?
【问题讨论】:
-
根据文档,这似乎是正确的做法:http://www.cplusplus.com/reference/stl/map/operator=/
-
你和用户Cute在几乎相同的时刻问非常相似的问题怎么会发生???
-
好的,但是问两次这个问题有什么意义呢?你们中的一个人可以提出这个问题,然后你们两个都可以看到答案。重复问题只会削弱社区的努力,而且你得到的答案也不太好。
-
(我把这两个相同的问题合并了)
标签: c++ visual-c++ stl append stdmap