Home Segments Index Top Previous Next

698: Mainline

Having divided your program into three files, you now note that each file contains a function that uses at least one function defined in another file. Thus, you cannot compile any file without providing the C++ compiler with information about those externally defined functions by way of function prototypes. The usual approach is to place those function prototypes in header files, which you then include where needed in other files:

// The rabbits.h file 
int rabbits (int); 
  
// The previous.h file 
int previous (int); 
  
// The penultimate.h file 
int penultimate (int);