6.9. Storage Classes and Storage Duration

The programs you’ve seen so far use identifiers for variable names and functions. The attributes of variables include name, type, size and value. Each identifier in a program also has other attributes, including storage duration, scope and linkage.

C++ provides five storage-class specifiers that determine a variable’s storage duration: register, extern, mutable and static. This section discusses storage-class specifiers register, extern and static. Storage-class specifier mutable is used exclusively with classes and thread_local is used in multithreaded applications—these are discussed in Chapters 21 and 24, respectively.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.