Your comparison function doesn't handle the case when the strings are equal.
bool Pet::operator <(Pet &right)
{
if (name.compare(right.name) < 0)
return true;
else if (name.compare(right.name) > 0)
return false;
}
string.compare
returns a negative value if it's less then it's argument, 0 when they are equal and a positive value when it's bigger. You don't handle the case when it returns 0 and it therefore falls off the end of the function which is undefined behavior.
Change the else if
to:
else if (name.compare(right.name) >= 0)
@Benjamin is right, your whole function could be shortened down to:
bool Pet::operator <(Pet &right)
{
return name.compare(right.name) < 0
}
I somehow always oversee these things when answering questions...