Using goto, break, continue, throw, or return inside the loop body can also have an undesirable effect. Here is another example where loop control and loop body are tightly intertwined. Does he write 1, 2, and 3 as before? Are you sure?
int value = 1; for (;;++value) { cout << value << endl; if (value != 4) continue; else break; }
Perhaps you think that we advise you not to use return expressions inside the bodies of the cycle more diligently. Do I really mean that? Yes. Functions that return something must do this with a single return statement at the very end of the function. Here are a few practical reasons:
Link
Disclaimer: not my material, I refer to the source
Myles Gray Feb 06 2018-11-12T00: 00Z
source share