Why not use: x = !x;?

Technically no in c++.

You apply a Boolean operator to an integer so the integer 0 is first promoted into a bool and becomes false and then the not operator is applied and you get true. So the type of !x is a bool, not an integer, and the value is true. (Which is its own thing in C++, unlike C)

If you use it where an int is expected then the rule will apply an true will be promoted into 1.