a question about map iterator
---code---
#include<map>
#include<iterat or>
using namespace std;
int main(){
map<string,int mp;
mp.insert(pair< string,int>("he llo",1));
for(map<string, int>::iterator it(mp.begin()); it<mp.end(); it+
+) ///----L---
cout<<it->first<<endl;
}
----code ----
it cannot compile; if I change the "it<mp.end( )" to "it!=mp.end ()"
in line L , it works.
for int vectors, I can use "it<vi.end( )" to make boundary check, but
for map it doesn't works.
any explaination or suggestions?
---code---
#include<map>
#include<iterat or>
using namespace std;
int main(){
map<string,int mp;
mp.insert(pair< string,int>("he llo",1));
for(map<string, int>::iterator it(mp.begin()); it<mp.end(); it+
+) ///----L---
cout<<it->first<<endl;
}
----code ----
it cannot compile; if I change the "it<mp.end( )" to "it!=mp.end ()"
in line L , it works.
for int vectors, I can use "it<vi.end( )" to make boundary check, but
for map it doesn't works.
any explaination or suggestions?
Comment