< previous page page_546 next page >

Page 546
at the beginning of every program that uses the Boolean type, we can put these three statements into a separate file named, say, bool.h. Then we use bool.h just as we use system-supplied header files such as iostream.h and math.h. By using an #include directive, we ask the C++ preprocessor to insert physically the contents of the file into our program. (Although many C++ systems use .h to denote header files, other systems use .hpp or .hxx.)
When you enclose the name of a header file in angle brackets, as in
#include <iostream.h>
the preprocessor looks for the file in the standard include directory, a directory that contains all the header files supplied by the C++ system. On the other hand, you can enclose the name of a header file in double quotes, like this:
#include bool.h
In this case, the preprocessor looks for the file in the programmer's current directory. This mechanism allows us to write our own header files that contain type declarations and constant declarations. We can use a simple #include directive instead of retyping the declarations in every program that makes use of them (see Figure 105).
From now on, the program examples in this book use the directive
0546-01.gif
Figure 10-5
Including Header Files

 
< previous page page_546 next page >