(C++) break
February 24, 2017 · View on GitHub
(C++) break
break is a keyword to
Consider to never use break, except in switch-statements or when the alternative would obscure the program's logic [1].
Example
- break example 1: break a for-loop
- break example 2: break a while-loop
- break example 3: break a switch statement
References
- Joint Strike Fighter Air Vehicle C++ Coding Standards for the System Development and Demonstration Program. Document Number 2RDU00001 Rev C. December 2005. AV Rule 191 (MISRA Rule 58): 'The break statement shall not be used (except to terminate the cases of a switch statement).' and 'Exception: The break statement may be used to 'break' out of a single loop provided the alternative would obscure or otherwise significantly complicate the control logic.'