Electrical and Computer Engineering
6 of 19
UAH
CPE 112
Scope Rules Explored
•void Block1(int, char&);
•void Block2();
•
•int a1;               // One global variable
•char a2;              // Another global variable
•int main()
•{
•   .
•   .
•   .
•}
•void Block1(int a1,   // Prevents access to global a1
•            char& b2) // Has same scope as c1 and d2
•{
•   int c1;          // A variable local to Block1
•   int d2;          // Another variable local to Block1
•     .
•     .
•     .
•}