Help On Writing Include Files for C or C++ Programs

When you write a program with many include files, you should build your include files like the following example:

-------------------- start of example --------------------

FILENAME: command.h

Here we define a data types for representing a command internally to the program.


#ifndef my_COMMAND_H
#define my_COMMAND_H

#include <string>

enum personType {DOCTOR, PATIENT} ;
enum comCategType {CHECKIN, CHECKOUT} ;
enum priorityType {GREEN, RED} ;

enum specialtyType {PED, GP, INT, CARD, SUR, OBS, PSY, NEUR, ORTH, DERM, OPH, ENT, ERROR} ;

struct commandType
} ;

-------------------- end of example --------------------

The directives:

insure that the file will not be included more than once in the image of the program that gets linked together when you call the compiler. Therefore, you will not get a lot of error messages complaining that things that have been defined already are being redefined.

Note the choice of the "uniquifier" prefix "my_" used to help avoid conflicts with constants that might be defined in system libraries.