範例
void
foo(
int
a,
int
b)
{
if
( a&b != 0 ) {
//先評估 b!=0
}
}
解決方案
請利用方括弧,確保會先評估位元運算子。
void
foo(
int
a,
int
b)
{
if
( (a&b) != 0 ) {
//先評估 (a&b)
}
}