8.1 Prototype

A prototype is a declaration. Let us consider the following example:

int sign(int x);

This statement is simply telling the compiler the following: ``just assume there is a subroutine sign defined somewhere that requires an integer parameter and returns an integer.'' This declaration makes the compiler happy because now it can perform parameter check and return value type checking.

Any subroutine that is cross referenced should have its prototype defined in a header file so that the referencing source files can #include the header file and know exactly how to use the subroutine.



Copyright © 2006-09-25 by Tak Auyeung