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

351 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 best solutions below

0
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
On

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

See Here