|
|
|
|
|
|
|
From the caller's perspective, a call to a void function has the flavor of a command or built-in instruction: |
|
|
|
|
|
|
|
|
DoThis(x, y, z);
DoThat(); |
|
|
|
|
|
|
|
|
In contrast, a call to a value-returning function doesn't look like a command; it looks like a value in an expression: |
|
|
|
 |
|
 |
|
|
Value-Returning Function A function that returns a single value to its caller and is invoked from within an expression. |
|
|
|
 |
|
 |
|
|
Void Function (Procedure) A function that does not return a function value to its caller and is invoked as a separate statement. |
|
|
|
|
|
|
|
|
For the next few chapters, we won't be writing our own functions (except main). Instead, we'll be concentrating on how to use existing functions, including functions for performing stream input and output. Some of these functions are value-returning functions; others are void functions. Again, we emphasize the difference in how you invoke these two kinds of functions: A call to a value-returning function occurs in an expression, while a call to a void function occurs as a separate statement. |
|
|
|
|
|
|
|
|
To format a program's output means to control how it appears visually on the screen or on a printer. If the variables i, j, and k contain the values 15, 2, and 6, respectively, the statement |
|
|
|
|
|
|
|
|
cout << "Results: " << i << j << k; |
|
|
|
|
|
|
|
|
outputs the stream of characters |
|
|
|
|
|