5.14 Wrap-Up

In this chapter, we completed our introduction to control statements, which enable you to control the flow of execution in member functions. Chapter 4 discussed if, ifelse and while. This chapter demonstrated for, dowhile and switch. We discussed the representational errors associated with floating-point types, then developed a DollarAmount class that used very large integers to precisely represent monetary amounts. We used only precise integer arithmetic when manipulating DollarAmounts. We showed that any algorithm can be developed using combinations of the sequence structure, the three types of selection statements—if, ifelse and switch—and the three types of iteration statements—while, dowhile and for. In this chapter and Chapter 4, we discussed how you can combine these building blocks to utilize proven program-construction and problem-solving techniques. You used the break statement to exit a switch statement and to immediately terminate a loop, and used a continue statement to terminate a loop’s current iteration and proceed with the loop’s next iteration. This chapter also introduced C++’s logical operators, which enable you to use more complex conditional expressions in control statements. In Chapter 6, we examine functions in greater depth.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset