int main()
{
bool b=true;
b!=b; // == true , but I thought b!=b == false
b=!b; // == false
}
Then I thought that b!=b should become b=b!b; (because a+=a equals a=a+a) but b=b!b; doesn't even compile. Shouldn't the compiler generate an error here?
x=!x assigns the negated value of x to x.
x!=x evaluates to true if x is different from x. Obviously, a value can't be different from itself, so unless x is an object that overload operator!=() in a special way, x!=x always evaluates to false.
x!x doesn't compile because ! is a unary operator. It only accepts one operand.