Chapter 5. Functions

Table of Contents

5.1. Overloading Functions
5.1.1. Exercises: Overloading Functions
5.2. Default (Optional) Arguments
5.3. Operator Overloading
5.3.1. Exercises: Operator Overloading
5.4. Parameter Passing by Value
5.5. Parameter Passing by Reference
5.6. References to const
5.7. Function Return Values
5.8. Returning References from Functions
5.9. Overloading on const
5.9.1. Exercises: Overloading on const
5.10. inline Functions
5.10.1. Inlining Versus Macro Expansion
5.11. Functions with Variable-Length Argument Lists
5.12. Exercise: Encryption
5.13. Review Questions

[ fromfile: functions.xml id: functions ]

Abstract

This chapter discusses the essentials of function overloading, function call resolution, default/optional arguments, temporary variables and when they're created, reference parameters and return values, and inline functions.

[Caution]Prerequisites

Functions in C++ are similar to functions and subroutines in other languages. C++ functions, however, support many features not found in some languages, so it is worthwhile discussing them here.