< Previous | Contents | Next >
In this chapter, you should have learned the following concepts:
n Functions allow you to break up your programs into manageable chunks.
n One way to declare a function is to write a function prototype—code that lists the return value, name, and parameter types of a function.
n Defining a function means writing all the code that makes the function tick.
184 Chapter 5 n Functions: Mad Lib
n You can use the return statement to return a value from a function. You can also use return to end a function that has void as its return type.
n A variable’s scope determines where the variable can be seen in your program.
n Global variables are accessible from any part of your program. In general, you should try to limit your use of global variables.
n Global constants are accessible from any part of your program. Using global constants can make your program code clearer.
n Default arguments are assigned to a parameter if no value for the param- eter is specified in the function call.
n Function overloading is the process of creating multiple definitions for the same function, each of which has a different set of parameters.
n Function inlining is the process of asking the compiler to inline a function—meaning that the compiler should make a copy of the function everywhere in the code where the function is called. Inlining very small functions can sometimes yield a performance boost.