Chapter 7. Functions

CONTENTS

Section 7.1 Defining a Function 226

Section 7.2 Argument Passing 229

Section 7.3 The return Statement 245

Section 7.4 Function Declarations 251

Section 7.5 Local Objects 254

Section 7.6 Inline Functions 256

Section 7.7 Class Member Functions 258

Section 7.8 Overloaded Functions 265

Section 7.9 Pointers to Functions 276

Chapter Summary 280

Defined Terms 280

This chapter describes how to define and declare functions. We’ll cover how arguments are passed to and values are returned from a function. We’ll then look at three special kinds of functions: inline functions, class member functions, and overloaded functions. The chapter closes with a more advanced topic: function pointers.

A function can be thought of as ...

Get C++ Primer, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.