I\'m wondering why I can\'t use STL maps with user-defined classes. When I compile the code below, I get the following cryptic error message. What does it mean? Also, why is
By default std::map (and std::set) use operator< to determine sorting. Therefore, you need to define operator<
on your class.
Two objects are deemed equivalent if !(a < b) && !(b < a)
.
If, for some reason, you'd like to use a different comparator, the third template argument of the map
can be changed, to std::greater, for example.