my code is like this:
struct Info { string name; int score; bool operator< (const Info &x) const { return score < x.score; } }; int main(int argc, char *argv[]) { Info a, b; a.name = "eric"; a.score = 90; b.name = "cat"; b.score = 85; map<Info, int> m; m[a] = 1; m[b] = 2; map<Info, int>::iterator it; for(it = m.begin(); it != m.end(); it++) { cout << it->first.name << endl; } return 0; } it prints out "cat" and "eric", as expected. but how ever, when I modify it to (make a.score and b.score the same)
Info a, b; a.name = "eric"; a.score = 90; b.name = "cat"; b.score = 90; It prints out "eric" only, there's only one element in the whole map.
question: does std::map think they are the same key? how do I make std::map think they are not the same key? I tried operator==, but not working.