Home Segments Index Top Previous Next

687: Mainline

With the header files properly included, you can use the C++ compiler to compile each source-code file separately, producing object code. The object-code files, by convention, have o extensions:

trains.cxx              containers.cxx          cars.cxx         
*--------------*        *--------------*        *--------------* 
| main         |        | Member-      |        | Member-      | 
| definition   |        | function     |        | function     | 
|              |        | definitions  |        | definitions  | 
|              |        |              |        |              | 
*--------------*        *--------------*        *--------------* 
       |                       |                       | 
       v                       v                       v 
trains.o                containers.o            cars.o           
*--------------*        *--------------*        *--------------* 
| Compiled     |        | Compiled     |        | Compiled     | 
| main         |        | member-      |        | member-      | 
| definition   |        | function     |        | function     | 
|              |        | definitions  |        | definitions  | 
*--------------*        *--------------*        *--------------* 

Most of the work required to translate source code into an executable program lies in producing object files. Fortunately, when you make changes in a big, multiple-file program, you need to recompile only the altered files; you leave unaltered files alone.