Sign in to follow this  
Gumgo

Maps question

Recommended Posts

Gumgo    968
Real quick question, with maps (#include <map>) can you have multiple elements with the same value? For example, map.insert( pair<char,int>("a",20) ); map.insert( pair<char,int>("b",20) ); That's all, thanks

Share this post


Link to post
Share on other sites
Deception666    182
Yes, you can do what you have asked. The keys in your example are different, so each insert into the map will not collide with an already inserted element. If you want to be able to insert elements with the same key, then I believe you want to use a multimap.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this