Currently skim through about c++, but at below example my brain stuck.
at the res
variable, example have preincrement of a
,b
and c
integer values.
When I print it out first one have output of a = 1, b = 0, c=0
at the second part output is a = 1, b = 0, c=0
int a, b, c;
a = 0;
b = 0;
c = 0;
res = ++a || ++b && ++c;
cout << '\n'
<< " res = " << res
<< ", a = " << a
<< ", b = " << b
<< ", c = " << c << endl;
a = b = c = 0;
res = ++a && ++b || ++c;
cout << " res = " << res
<< ", a = " << a
<< ", b = " << b
<< ", c = " << c << endl;
both of them I'm expecting output as a = 1, b = 1, c=1
because I have already incremented variables.
From output I understand if after ||
operator, nothing is evaluated? I need clarification. Thanks.