Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) break

 

break is a keyword to

  1. end a for-loop
  2. end a while-loop
  3. end a switch-statement

 

Consider to never use break, except in switch-statements or when the alternative would obscure the program's logic [1].

 

 

 

 

 

Example

 

 

 

 

 

 

References

 

  1. 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.'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict