What does iterator -> second mean?

Im studying c++ and ive just started with template and classes, and they confuse me alot.
Im trying to make winsock server that needs to parse messages and one way to do that is to enumerate the messages needed, and then recieve a string from the client. So i need to match a string to an enumeration.
I have the piece of code below but I do not understand what i->second means?



#include <map>
#include <string>
#include <iostream>
using namespace std;
enum MyEnum {blue, green, yellow};

void foo(MyEnum s){
std::cout << "foo called with s = " << s;
}

int main(){



map<string, MyEnum> dictionary;
dictionary["blue"] = blue;
dictionary["green"] = green;
dictionary["yellow"] = yellow;

map<string, MyEnum>::iterator i = dictionary.find("green");
if( i != dictionary.end() )
foo( i->second );
return 0;
}

closed account (o1vk4iN6)
It's a pair type.

http://cplusplus.com/reference/utility/pair/

Look at the iterator and value_type.

http://cplusplus.com/reference/map/map/

Topic archived. No new replies allowed.