> 优先级高于 &

if (2 & 2 > 1)
{
// something wrong?
cout <<"I don't think this line could display..." <<endl ; // 1)
}
//if
观察上述代码, 问: 语句 1) 能被执行么?
答案是: 不能执行. 
                       2 & 2 > 1        红色部分先判断, 因为 > 优先级高于 & .
  
if ((2 & 2) > 1) // (2 & 2)括号不能少
{
// something wrong?
cout <<"I don't think this line could display..." <<endl ; // 1)
}//if

posted @ 2011-06-25 16:53  walfud  阅读(140)  评论(0编辑  收藏  举报