Showing posts with label storage duration. Show all posts
Showing posts with label storage duration. Show all posts

Saturday, July 23, 2011

Storage Class Specifiers and Name Scope in C++

The following is part of a contribution I made to one of the pages on the
Qt Centre Community Wiki, titled "Going Out of Scope":


In C++, as in many other languages, variables have scope; i.e., a variable or function name can be used only within certain parts of a program. This "area of visibility" is referred to as the name's scope. Additionally, C and C++ also employ the concepts storage duration and linkage. Storage duration determines how and when during program execution an identifier exists in memory – the lifetime of its storage. Linkage affects a name's visibility across translation units (the contents of a single source file, plus the contents of any header files included by it).

The two concepts that are most relevant here are scope and storage duration.