20.2 Name Scopes (cont.)

Scopes may nest

int count = 0; // Create a global variable
. . .
int count_items()
{
   int orig_count = count; // holds value in global variable
   int count = 0; // A different variable named count
   for (...)
      count++; // Increment the local variable
   return count + orig_count;
}
// Local count and orig_count are no longer available,

prev |top |next