Visibility, Lifetime, and Access
We have talked about creating our own types and declaring variables and functions while mainly focusing on simple functions and a single file. We will now look at what happens when there are multiple source files (translation units) that contain classes and function definitions. Also, we'll check which variables and functions can be visible from the other parts of the source files, how long the variables live, and look at the difference between internal and external linkage. In Chapter 1, Anatomy of Portable C++ Software, we saw how the toolchain works to compile the source files and produce the object files and that the the linker puts it all together to form an executable program.
When a compiler processes a source file, it generates an object file that contains the translated C++ code and enough information for the linker to resolve any references from the compiled source file to another source file. In Chapter 1, Anatomy of Portable C++ Software,...