previous | start

## Separate Compilation

- Special code for the compiler must be put in a header file to prevent the file from being compiled twice.

  >     #ifndef PRODUCT_H
  >     #define PRODUCT_H
  >     . . .
  >     #endif

- The source file includes its own header file.

  >     #include "Product.h"

- The source file does not contain a main function because many programs may use this class.
- Shared constants are placed in the header file.
- To share global variables among source files, declare them in a header file as extern.

  >     extern GraphicWindow cwin;

  The source file contains the definition.

  >     GraphicWindow cwin;

previous | start