How to create iterator/s for 2d vector (a vector of vectors)?
Suppose you have a vector like this:-
vector
Now to use iterators with 2D vectors :-
for(auto i = vect.begin() ; ibegin() ; jend() ; j++)
cout << *j <<" ";
cout <<"\n";
//similarly you can do other things
}
Also other shorter way is
for(auto i : vect)
{
for(auto j : i)
cout << j <<" ";
cout << "\n";
//similarly you can do other things also.
}
Please note the way of calling variables is different in both the cases.