"invalid operands of types bool 'and' 'to binary' <<'"
This means that the second operator << trying to execute on (! T) and 'endl'.
<< takes precedence over && , so your cout statement is executed as follows:
(cout << t ) && ( (!t) << endl );
Add brackets to fix this:
cout << (t && (!t) ) << endl ;
Look here for the order of operations when statements are not evaluated as expected.
source share