These are guidelines for CSCI121 Spring Session 1997. They do not have "departmental status".
Lecturers for other subjects require different styles. Confirm with lecturer when starting a subject.
These guidelines contain internal cross references indicated by underlining.
"Physically" a program is built by compiling and linking together:
a file with the main program (usually named main.cpp)
a number of separate modules (X.h/X.cpp file pairs)
functions taken from standard libraries.
A module is a separately compilable part of a C/C++ program. A module will consist of two files –
the "header" file and the "implementation" file. The header file defines the services that the module
provides to the rest of the program. The implementation file contains the code that is used to supply
There are different styles of module. These suit different approaches to program design.
A module for a program designed using top-down functional decomposition:
The header file will contain:
• A list of function prototypes and comments summarizing the functions provided (using a term from
another programming language, you could say that these are the functions that are "exported" by
Constants and typedefs might also be in the header file; and sometimes there may even be struct
declarations. However, these should be minimized.
The implementation file will contain:
• Declarations of any structs used only by functions defined in that module.
• Definitions of any constant data used by those functions.
• Definitions of any static (filescope) variables used to retain state information between successive
calls to functions "exported" by the module.
• Definitions of the functions listed in the module's header file (the "exported" functions).
• Definitions of any static auxiliary functions needed to simplify implementation of "exported"
A module for a program designed using an object based (or object oriented) approach
A module for an object