There are four types of scope. The names and properties of these four types of scope may be defined as follows.

A name that is declared outside all blocks and classes is said to have file or global scope. Following its declaration, such a name may be used within the translation unit of its occurrence.
A name that is declared within a block is said to have local scope. Subsequent to its declaration, such a name may be used only within the block in which it is declared. The formal parameters of a function have local scope and are visible to the outermost block of the function.
The names of the members of a class have scope local to the class. Methods of the class (or the methods of classes deriving therefrom) may access such names without qualification. Non-member functions are required to access non-static members of a class via the member access operators . and ->. The operator . is applied to an instance of a class. The operator -> is applied to a pointer to an instance of a class. A class that is first declared as a parameter or return type has global scope.
Identifiers used to label statements are of function scope. Only label identifiers have function scope. Label identifiers may be used anywhere within the function in which they are defined.


A name becomes visible as soon as its declarator is seen by the compiler, and before its initializer (if any) is processed. Special rules apply to the names declared as formal parameters of a function.

See the topic titled scope rules in the subsection on inheritance for a summary of the rules that apply to the concept of scope.

Visibility of Names

The following applies to the visibility of names.