Map Iterator

I've got the following map and the following code to loop through my map.

1
2
3
4
5
6
map<std::string,std::vector<std::string> > resKey;

typedef map<std::string,std::vector<std::string> >::resKey it_type;
for (it_type iterator=resKey.begin(); iterator != resKey.end(); ++iterator){
 <some code here>
}


I am getting the following compiler error, which I believe is coming from a typo or something which I am not able to find.

 
>3: error: ‘resKey’ in class ‘std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >’ does not name a type
resKey on line 3 should probably be iterator.
Last edited on
The problem is your typedef.
It should be:
 
typedef map<std::string,std::vector<std::string> >::iterator it_type;


Last edited on
You were right. I must have used a bad template I found online. Thank you.
Topic archived. No new replies allowed.