hi all...
i found this code in some past discussion on this forum.i do not understand why operator overloading is necessary.if i remove it iam getting errors...
i found this code in some past discussion on this forum.i do not understand why operator overloading is necessary.if i remove it iam getting errors...
Code:
#include <map>
class Keys {
public:
Keys(int k1, int k2)
{
key1=k1;
key2=k2;
}
bool operator<(const Keys &right) const {
return (key1 < right.key1 && key2 < right.key2);
}
int key1;
int key2;
};
int main() {
std::map<Keys, int> mymap;
mymap.insert(std:air<Keys, int>(Keys(3, 8), 5));
return 0;
}
Comment