|Functional Average II||average4.c||C++ Functions|
void print_it(int n1, int n2, int n3, double av);
is called a prototype. It is used when the call will precede the function itself in the program. Java doesn't worry much about the relative location of the definition of a method and its use. Just as variables, functions need to be defined before they are used.
Note that the parameter names given in the prototype are ignored by the compiler. They need not agree with those used in the function itself, and may be omitted entirely. Only the type and number must be the same.
If the prototype is omitted in C++, it is straightforward error. If you omit one in C, the situation is a bit more complicated. The result can be compiler messages which are less than helpful. The reasons are historical, and form a long story.
|Functional Average II||C++ Functions|