用赋值表达式作为bool值

 1 enum Status
 2 {
 3     stOk,
 4     stQuit,
 5     stError
 6 };
 7 
 8 
 9 int main()
10 {
11     Status status;
12     int n;
13     bool b1 = (status = stOk);        //false
14     bool b2 = (n = 0);                //false
15     bool b3 = (n = 1);                //true
16 }

总结:结果并非一直为true,得看后面赋的值是否为0

原文地址:https://www.cnblogs.com/XiaoXiaoShuai-/p/11623393.html