Introduction

 < Day Day Up > 



Control flow statements are a critical component of the C++ programming language, for without them processing would proceed from beginning to end with no detours and how boring would that be?

In this chapter I will show you how to use the selection statements if, and switch. Selection statements allow you to evaluate an expression and continue processing in a direction based on the result of an expression.

The selection statements will be followed by the iteration statements while, do, and for. Iteration statements are used to do repetitive processing controlled by the evaluation of an expression. I will also cover the use of labeled statements, goto statements, break statements, continue statements, and null statements.

Whatever you do, don’t forget the material covered in chapter 5. Most of the operators introduced there can be used to build the expressions used in the selection and iteration statements.

Along the way I will show you the idiomatic way of writing each type of statement. Idioms are important in C++ and other languages because knowing the accepted way of writing a while loop, for loop, etc., increases the readability of your code while reducing the opportunity to introduce syntax errors or logic flaws into your programs.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net