Which side (left or right) of && (and) operator evaluated in C++

c++, logical-operators, operator-precedence

Solution

This gets parsed as:

if (int alpha = (value1-value2 && (alpha > 0.001)))

... because `&&` has a higher "parsing precedence" than `=` -- which is probably not what you want. Try:

int alpha = value1-value2; 
if (alpha && (alpha > 0.001))

Problem

Which order is the and && operator evaluated For example the following code ``` if (float alpha = value1-value2 && alpha > 0.001) //do something ``` threw an exception that alpha is being used without being initiated. I thought the expression left of the && would always initiate the value of alpha first, but it seems I may be wrong Any idea? Thanks

Original source

Related problems