a =! b
is just a funny way of putting
a = !b
i.e. the assignment of not b
to a
.
The value of the expression is a
after the assignment.
With the code below you can see that the value of the expression a = !b
is !false
(i.e. true
), and you can then see the assignment has taken place by checking the value of a
, which is also true
.
#include <iostream>
int main()
{
bool a = false;
bool b = false;
if(a)
printf("a is true!\n");
else
printf("a is false!\n");
if(a = !b)
printf("expression is true!\n");
else
printf("expression is false!\n");
if(a)
printf("a is true!\n");
else
printf("a is false!\n");
}
Result:
a is false!
expression is true!
a is true!