Document last modified:
Give the static scoping diagram.
What is the result with static scoping?
Give the dynamic scoping diagram.
What is the result with dynamic scope?
int z = 2; int add ( int f(int), int z) { return f (z); }
int p(int x) { return x+z; }
void main() { cout << add( p, 3); }
3. (12 pts) What is the output of the following for:
#include <iostream.h>
int I = 0;
int A[3] = { 7, 11, 13 };
void P(int x, int y) {
y = 1;
cout << x << "\t";
I = 2;
cout << x << "\t";
I = 2;
cout << x << "\t";
cout << y << "\n";
}
void main() {
P( A[I], I );
P( I , A[I] );
}
|