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 a programmer-defined operation. Like the built-in operators, each function performs some computation and (usually) yields a result. Unlike the operators, functions have names and may take an unlimited number of operands. Like operators, functions can be overloaded, meaning that the same name may refer to multiple different functions.



C++ Primer
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2006
Pages: 223
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net