Static Storage Duration

Keywords extern and static declare identifiers for variables with static storage duration and for functions. Variables with static storage duration exist in memory from the point at which the program begins execution and until the program terminates. Such a variable is initialized once when its declaration is encountered. For functions, the name of the function exists when the program begins execution. Even though function names and static-storage-duration variables exist from the start of program execution, their identifiers cannot necessarily be used throughout the program. Storage duration and scope (where a name can be used) are separate issues, as we’ll see in Section 6.10.

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.