bool operator == (const MyString& left, const MyString& right)
{
if(left.value == right.value)
return true;
else return false;
}
bool operator != (const MyString& left, const MyString& right)
{
if(left == right)
return false;
else
return true;
}
bool operator < (const MyString& left, const MyString& right)
{
if(strcmp(left.value, right.value) == -1)
return true;
else
return false;
}
bool operator > (const MyString& left, const MyString& right)
{
if(strcmp(left.value, right.value) == 1)
return true;
else
return false;
}
bool operator <= (const MyString& left, const MyString& right)
{
if(strcmp(left.value, right.value) == -1 || strcmp(left.value, right.value) == 0)
return true;
else
return false;
}
bool operator >= (const MyString& left, const MyString& right)
{
if(strcmp(left.value, right.value) == 1 || strcmp(left.value, right.value) == 0)
return true;
else
return false;
}
These are my implemented comparison operators for my MyString class, but they fail the test program that my professor gave me and could use some direction. What is the problem?
You can express each comparator with just two of them: