
Prelab Activities
Review
In Chapter 8, we said that local variables are those declared within a block. The block
does not have to be the body of a function—local identifiers can be declared within any
block. In a large program, there may be several variables with the same identifier—
name, for example. How do we know which variable is meant and where each variable
is accessible? The answers to these questions are provided by scope rules.
Scope of an Identifier
There are four categories of scope for an identifier in C++: class scope, local scope,
namespace scope, and global scope. Class scope is defined in Chapter 11. Local scope is
the scope of an identifier ...