1.Automatic storage duration—Variables declared inside a function definition—includ-
ing function parameters—have automatic storage duration. They are created when pro-
gram execution enters the function or block in which they are defined, and the memory
used for them is freed when execution leaves the function or block. C++ has two kinds
of automatic storage duration variables.
2.Static storage duration—Variables defined outside a function definition or else by
using the keyword static have static storage duration. They persist for the entire time a
program is running. C++ has three kinds of static storage duration variables.
3.Dynamic storage duration—Memory allocated by the new operator persists until it is
freed with the delete operator or until the program ends, whichever comes first. This
memory has dynamic storage duration and sometimes is termed the free store.
4.Scope describes how widely visible a name is in a file (translation unit). For example, a vari-
able defined in a function can be used in that function, but not in another, whereas a variable
defined in a file above the function definitions can be used in all the functions.
5.Linkage describes how a name can be shared in different units. A name with external linkage can be
shared across files, and a name with internal linkage can be shared by functions within a single
file. Names of automatic variables have no linkage because they are not shared.
6.C++, like C, supports the register keyword for declaring local variables. A register variable is
another form of automatic variable, so it has automatic storage duration, local scope, and no
linkage. The register keyword is a hint to the compiler that you want it to provide fast access
to the variable, perhaps by using a CPU register instead of the stack to handle a particular vari-
able. The idea is that the CPU can access a value in one of its registers more rapidly than it can
access memory in the stack. To declare a register variable, you preface the type with the key-
word register
参考:C++ PRIMER PLUS, 5th edition , P422 , Storage Duration, Scope, and Linkage