int index = 3;
map<int, Class> list;
std::map<int, Class>::iterator test = list.begin();
std::advance(test, index);
for(map<int, Class>::iterator it = test; it != list.end();++it)
{
cout << it->first << " " << it->second.GetPrice() << endl;
}
Hi Everyone,
Please help me on this issue. I know how to start at a certain position of the forloop but i am not able to end the loop at certain position.
Let's say for a normal for loop, [Pls see below].
int start = 2;
int end = 4;
for ( int i = start; i < end; i++)
{
}
Let's say the list have 10 index and i only want to loop the list from index 2 to 4 only. I only want to values from index = 2 till index = 4. How do i do that using iterator? Can someone please guide?
Please let me know if you don't understand.