Creating
names is a fundamental activity in programming, and when a project gets large
the number of names can easily be overwhelming. C++ allows you a great deal of
control over both the creation and visibility of names, where storage for those
names is placed, and linkage for names.
The
statickeyword
was overloaded in C before people knew what the term “overload”
meant, and C++ has added yet another meaning. The underlying concept with all
uses of
static
seems to be “something that holds its position” (like static
electricity), whether that means a physical location in memory or visibility
within a file.
In
this chapter, you’ll learn how
static
controls storage and visibility, and an improved way to control access to names
via C++’s
namespace
feature. You’ll also find out how to use functions that were written and
compiled in C.