Hi i have custom key defined as shown below. When i create a std::map, i was under the impression that map will refer to operator== defined in my key to detect if two keys are same, but its not true. Can you please point me to correct logic for eliminating duplicates from this map?
class Key
{
public:
Key(char * init, long l): equipNumber(l)
{
memcpy(initials, init, sizeof(initials));
}
bool operator==(const Key & other) const
{
bool result = true;
cout << "Comparing: " << initials << " with " << other.initials;
result &= (!memcmp(initials, other.initials, sizeof(initials)));
cout << " And result is: " << result << endl;
cout << "Comparing: " << equipNumber << " with " << other.equipNumber << endl;
result &= (equipNumber == other.equipNumber);
return result;
}
bool operator<(const Key & other) const
{
bool result = true;
result &= (equipNumber < other.equipNumber);
return result;
}
private:
char initials[5];
long equipNumber;
};