Evaluation of the following expression

后端 未结 3 1433
别跟我提以往
别跟我提以往 2021-01-26 03:25

The following code snippet:

int i=-3,j=2,k=0,m;

m=++i && ++j || ++k;

can be evaluated using two concepts,I believe:

1.Since ++

3条回答
  •  时光取名叫无心
    2021-01-26 04:17

    Oli is right... You're confusing precedence with evaluation order.

    Precedence means that the expression is interpreted as:

    m = ((((++i) && (++j)) || (++k));
    

    As opposed to, say:

    m = (++(i && ++(j || (++k)))
    

    Precedence doesn't change the fact that the LHS of the || operator will always be evaluated before the RHS.

提交回复
热议问题