(*it).second. How this keyword works?

346 views Asked by At
for(it=visited.begin(); it!=visited.end();++it)
        {
            if((*it).second>ttl){
                ++count;
            }
        }

What does the line if((*it).second>ttl) means here ?

For better understanding see this code please .... http://ideone.com/NY4ofJ . Thanks in Advance .

2

There are 2 answers

0
Leeza On BEST ANSWER

A map is a collection of pair ; with a key and a value. To access to the key you use the member first and to access to the value you use member second.

(*it).second or it->second dereference the iterator and get the second value of the pair contains in the map.

So, the value contained by the iterator is tested with the value contained by the ttl variable.

0
ssavi On

The line in the question points to the second value of a Map or Pair ... for more :

See Here