Operator precedence and evaluation order

前端 未结 5 2187
梦如初夏
梦如初夏 2021-02-09 05:37

I can\'t understand output of this program:

#include
using namespace std;
int main()
{
    int x = 1 , y = 1, z = 1;
    cout << ( ++x || +         


        
5条回答
  •  悲哀的现实
    2021-02-09 06:10

    ( ++x || (++y && ++z )) - can be seen as boolean values - only ++x is evaluated. Its int value is 2 and the boolean value is 1 (true).

提交回复
热议问题