Chapter 6

Creating Functions

In This Chapter

arrow Writing functions

arrow Passing data to functions

arrow Naming functions with different arguments

arrow Creating function prototypes

arrow Passing by value versus passing by reference

arrow Providing default values for arguments

The programs developed in prior chapters have been small enough that they can be easily read as a single unit. Larger, real-world programs are often many thousands if not millions of lines long. Developers need to break up these monster programs into smaller chunks that are easier to conceive, describe, develop, and maintain.

C++ allows programmers to divide their code into just such chunks known as functions. A function is a small block of code that can be executed as a single entity. This allows the programmer to divide her program into a number of such entities, each that implements some well-defined subset of the overall program. Functions ...

Get C++ For Dummies, 7th 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.