next up previous
Next: Input/Output Up: C Primer CS 1005 Previous: switch

Functions

In most non-trivial programs, functions need to be declared before their implementation is given (``prototypes''). Normally, this is done in the ``header''-file (ending on .h) belonging to a C$^{++}$-file. Variable names can be omitted in the prototype (and types in the implementation) if that does not lead to confusion. maximum.h

// Prototype:
int max(int , int );
maximum.cxx

#include "maximum.h"

// Implementation:
int max (int a, int b) {
   int max;
   if (a>b) max = a;
   else     max = b;
   return max;
}


Andreas Koeller
2000-06-04