You need to define operator <
for the Class1.
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;
};