用赋值表达式作为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

posted @ 2019-10-04 21:35  机智的小小帅  阅读(296)  评论(0编辑  收藏  举报