Chapter 5. Functions

One of the key elements of most any programming language is that of function—which other languages sometimes refer to as “subroutine,” “procedure,” or “subprogram.” It’s a semiautonomous part of the program you can transfer control to and come back from.

Some languages have a different syntax for subroutines that return values as opposed to those that don’t. But C++ considers them all functions whether they return a value or not.

read_in_file("readme.txt");   // Call read_in_file funct.

Traditionally, in C++ you must declare a function and give it a name before calling it. Most of this chapter describes that traditional approach.

The new C++11 specification also supports a new syntax called lambda, or anonymous, functions—functions ...

Get C++ for the Impatient now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.