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
You need to define operator < for the Class1.
operator <
Map needs to compare the values using operator < and hence you need to provide the same when user defined class are used as key.
class Class1 { public: Class1(int id); bool operator <(const Class1& rhs) const { return id < rhs.id; } private: int id; };