Overview
Chapter 6 focuses on functions. First, students will learn more about the predefined
functions in C++. Then they will learn about the use of user-defined functions to break a
program into manageable pieces. Students will examine the mechanics of writing their
own functions, including how to use parameters and return values. They will also
examine reference parameters and learn how to use them in a program. The scope of
identifiers will be examined in depth, as well as the purpose and use of static variables.
Finally, students will be introduced to the concept of function overloading.
Objectives
In this chapter, the student will:
• Learn about standard (predefined) functions and discover how to use them in a program
• Learn about user-defined functions
• Examine value-returning functions, including actual and formal parameters
• Explore how to construct and use a value-returning, user-defined function in a program
• Learn about function prototypes
• Learn how to construct and use void functions in a program
• Discover the difference between value and reference parameters
• Explore reference parameters and value-returning functions
• Learn about the scope of an identifier
• Examine the difference between local and global identifiers
• Discover static variables
• Learn how to debug programs using drivers and stubs
• Learn function overloading
• Explore functions with default parameters
Teaching Tips
Introduction
1. Point out that only the main function has been used in the programming examples thus
far in the text.
2. Explain that functions are like building blocks (often called modules), which can be
combined to form a larger program.