Non-portable random behaviour.
Output:Code:int main() { map<int, int> Map; Map.insert(pair<int, int>(1,2)); Map.insert(pair<int, int>(1,3)); map<int, int>::iterator itr = Map.lower_bound(1); cout << itr->second << endl; ++itr; if(itr == Map.end()) { cout << "Thought so." << endl; } else { cout << itr->second << endl; } }Dereferencing the end() iterator yields undefined behaviour.Code:2 Thought so.




CornedBee
Reply With Quote