The assignment operator in C++ returns the value of the assignment to make chaining possible:
int a = b = c = 3;
After this assignment
a, b, c will all be equal to 3.
This line is also equal to
int a = (b = (c = 3));
In C++ assigning int to bool is made with implicit cast, and
bool b = (x = 3);
will result to 1.
Thus the loop condition will always evaluate to true and we get infinite loop.
Login in to like
Login in to comment