Map and find
Hi again...
I worked in C++ years ago, and I may have forgotten many things :) So I ask (and I'll probably keep asking) here - I've found useful answers in a previous post.
I read from Stroustrup, C++, 3rd edition, that STL's map requires only the comparision "less than" operator for the keys. But I don't understand how can map.find() work, if there is only the opreator "less than".
Imagine I use a map<string,anythong> - I have two strings:
which are two different objects. If I use them as keys in the map, how does the map know that those are the same key? I've not really tried that, but what I see from examples is that map would consider s1 and s2 the same key.
How to know that having only the "less than" operator? I think I'm missing some basic point, but I don't get it, neither could find it over the google's net.
Thanks!
I worked in C++ years ago, and I may have forgotten many things :) So I ask (and I'll probably keep asking) here - I've found useful answers in a previous post.
I read from Stroustrup, C++, 3rd edition, that STL's map requires only the comparision "less than" operator for the keys. But I don't understand how can map.find() work, if there is only the opreator "less than".
Imagine I use a map<string,anythong> - I have two strings:
string s1 = string("Hello");
string s2 = string("Hello");
which are two different objects. If I use them as keys in the map, how does the map know that those are the same key? I've not really tried that, but what I see from examples is that map would consider s1 and s2 the same key.
How to know that having only the "less than" operator? I think I'm missing some basic point, but I don't get it, neither could find it over the google's net.
Thanks!
