operator precedence

14 Nov 2010


this always return a false

bool SMSConfig::getActSI()
    {
    if (actions & STATUSIP == 0)
        return false;
    else 
        return true;
    }
but this works

bool SMSConfig::getActSI()
    {
    if ((actions & STATUSIP) == 0)
        return false;
    else 
        return true;
    }


which seems a little odd.

15 Nov 2010 . Edited: 15 Nov 2010

== has a higher precedence than &, hence STATUSIP==0 is evaluated first.

BTW you can also do:

return actions & STATUSIP;