Electron microscopy
 
EXTERN Storage Specifier in C++
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

In practice, computer programs tend to be very large. As a program file grows, the compilation time becomes long enough to be annoying. When this happens, the program is normally splitted into two or more separate files. Once the program is divided this way, small changes to one file will not require that the entire program be recompiled. The multiple file approach can yield a substantial time efficiency with large projects. The extern keyword in C++ helps support this approach.

In a program that consists of two or more files, each file must know the names and types of the global variables used in the program. However, the copies of the global variables in each file cannot be simply declared. The reason is that in C++, each program can include only one copy of each global variable. If you try to declare the global variables needed by your program in each file, then you will have trouble. When the linker tries to link together the files, it will find the duplicated global variables, and then will not link your program. The solution to this dilemma in C++ is to declare all of the global variables in one file and use extern declarations in the others.

 

 

 

 

=================================================================================