Aug 17th, 2002, 02:34 PM
i am using a message map for message handling in my win32 window wrapper. i found a reference on the net, and one line has this:
further on, it does this with the iterator:
typedef tyMessageMap::iterator tyMessageIterator;
when i try to access the second member with the -> operator it desont' show anything..thats cuz ints not a pointer..i tried the . operator, but the iterator doesn't even have a second member..i looked on the STL doc and it doesn't have that member either..what do i need to use instead?
return it->second; //what does this do anyways?
The Power of Learning.
Aug 17th, 2002, 05:43 PM
That iterator class (std::map<A,B>::iterator) has an overloaded operator -> and operator *
So "it->second" is actualy "it.operator ->()->second"
The operator -> returns a std::pair<A,B>*
A std::pair has a second member which is what you are accessing.
If it returns nothing (what is nothing? Empty string? NULL pointer, 0?) that means that that's the value (first is the key) of that item in the map.
You should also make sure that
which would indicate an error (usualy searched item not found)
Click Here to Expand Forum to Full Width
Survey posted by VBForums.