< previous page page_337 next page >

Page 337
0337-01.gif
As you can see in the syntax template, no body is included for the function, and a semicolon terminates the declaration. The formal parameter list is optional and has the form
0337-02.gif
The ampersand (&) attached to the name of a data type is optional and has a special significance that we cover later in the chapter.
In a function prototype, the formal parameter list must specify the data types of the parameters, but their names are optional. You could write either
void DoSomething( int, float );
or
void DoSomething( int velocity, float angle );
Sometimes it's useful for documentation purposes to supply names for the parameters, but the compiler ignores them.
Function Definitions
You learned in Chapter 2 that a function definition consists of two parts: the function heading and the function body, which is syntactically a block (compound statement). Here's the syntax template for a function definition, specifically for a void function:
0337-03.gif

 
< previous page page_337 next page >