注册 登录
编程论坛 C++教室

multimap重复键值的赋值~~~~~

kisscjy 发布于 2007-08-14 22:19, 2312 次点击

有一个程序:
#include<iostream>
#include<map>
using namespace std;

void main()
{
multimap< int , int > mp;
mp.insert(0 , 2);
mp.insert(0 , 3);

}

multimap不是允许重复键的吗?
我希望0是关键值,然后2,3分别与0相关联~
但是编译不能通过,想问一下大家究竟为什么不能通过呢?

5 回复
#2
kisscjy2007-08-15 10:13
不要沉下去啊~~顶起来~~
#3
neverDie2007-08-15 12:06
mp.insert(0 , 2);


括号里是什么类型?你查清楚先!
#4
kisscjy2007-08-15 19:16

难道就没有人知道么?

#5
aipb20072007-08-16 10:22

3楼说了啊!

[CODE]MSDN:
iterator insert(
const value_type& _Val
);
The value_type of an element is a pair, so that the value of an element will be an ordered pair with the first component equal to the key value and the second component equal to the data value of the element.[/CODE]

#6
tfg01162008-10-25 21:40
#include<iostream>
#include<map>
using namespace std;

void main()
{
multimap<int, int> mp;
mp.insert(make_pair(0, 2));
mp.insert(make_pair(0, 3));
}
往map容器中insert的格式应该记住
1