www.gibmonks.com

Main Page




Previous Page
Next Page

[Page 305 (continued)]

6.23. Wrap-Up

In this chapter, you learned more about the details of function declarations. Functions have different pieces, such as the function prototype, function signature, function header and function body. You learned about argument coercion, or the forcing of arguments to the appropriate types specified by the parameter declarations of a function. We demonstrated how to use functions rand and srand to generate sets of random numbers that can be used for simulations. You also learned about the scope of variables, or the portion of a program where an identifier can be used. Two different ways to pass arguments to functions were coveredpass-by-value and pass-by-reference. For pass-by-reference, references are used as an alias to a variable. You learned that multiple functions in one class can be overloaded by providing functions with the same name and different signatures. Such functions can be used to perform the same or similar tasks, using different types or different numbers of parameters. We then demonstrated a simpler way of overloading functions using function templates, where a function is defined once but can be used for several different types. You were then introduced to the concept of recursion, where a function calls itself to solve a problem.

In Chapter 7, you will learn how to maintain lists and tables of data in arrays. You will see a more elegant array-based implementation of the dice-rolling application and two enhanced versions of our GradeBook case study that you studied in Chapters 35 that will use arrays to store the actual grades entered.


Previous Page
Next Page