I want to compare four integers and see whether they are equal or not. So wrote the following,
int a = 1, b = 2, c = 3, d = 4;
if (a != b != c != d)
{
//do something
}
This apparently shows no error. But, in fact, giving the wrong answer. Can someone explain this, please?
you have to compare each pair, there's no shortcut:
or, you can also throw these variable in an
std::set
and check if the size is 4also, your code compiles because it's equal to
or something similar