Chapter 6. Functions
Contents
- Section 6.1 Function Basics
- Section 6.2 Argument Passing
- Section 6.3 Return Types and the
return
Statement - Section 6.4 Overloaded Functions
- Section 6.5 Features for Specialized Uses
- Section 6.6 Function Matching
- Section 6.7 Pointers to Functions
- Chapter Summary
- Defined Terms
This chapter describes how to define and declare functions. We’ll cover how arguments are passed to and values returned from functions. In C++, functions can be overloaded, which means that we can use the same name for several different functions. We’ll cover both how to overload functions and how the compiler selects the matching version for a particular call from several overloaded functions. The chapter closes by describing pointers to functions.
A function is a block of code with a name. We execute the code by calling the function. A function may take zero or more arguments and (usually) yields a result. Functions can be overloaded, meaning that the same name may refer to several different functions.