By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Accessing Map elements randomly

P: 10
I have a need to randomly access a Map element.
For this I tried:

int entry ; //Randomly generated
map<int, int> blah;
map<int, int>::iterator blahI;

blahI = element + blah.begin();

But the compiler complains. I need to get an iterator to a particular element.
Sep 26 '06 #1
Share this Question
Share on Google+
1 Reply

P: 293
Iterators should support relative addressing. Why don't you change your code to
Expand|Select|Wrap|Line Numbers
  1. data = *(entry+blah.begin());
and see if it likes it.
Sep 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.