![]() |
![]() |
![]() |
![]() |
![]() |
|
Suppose, for the sake of illustration, that you decide to divide
the analyze_train program into three files:
trains.cxx containers cars *--------------* *--------------* *--------------* | main | | box | | railroad_car | | | | cylinder | | box_car | | | | | | tank_car | | | | | | engine | | | | | | caboose | *--------------* *--------------* *--------------*
When the analyze_train program is so divided, you could use
#include declarations to incorporate the text in the
containers file and the cars file back into the
trains.cxx file:
#include "containers" #include "cars" ...
When the C++ compiler sees such #include declarations, it
suspends its examination of the current file temporarily and
pretends that the text of the included file is actually in
the current file at that place:
containers cars
*-------------* *-------------*
| | --* | | --*
| | | | | |
*-------------* | *-------------* |
| |
trains.cxx | |
*--------------------------* | |
| #include "containers" <------------------* |
| #include "cars" <---------------------------------------------*
| |
| ... |
*--------------------------*