file1和file2是同一工程下的两个源文件,示例c++作用域。
int a = 1, b = 2;
int c = 10, d = 11;
void f1(int n, int m)
{
int x = 21, y = 22, z = 23;
extern int h, k;
n = n + t;
if (n > 100)
{
int x = 31, t = 20;
n = x + y;
if (m > 10)
{
int y = 41;
n = x + y;
}
}
n = a + x;
n = e + f;
n = h + k;
}
int e = 50, f = 51;
int h = 60, k = 61;
void f2(int n, int m)
{
n = a + b + e + f;
m = z;
}
int f3(int n, int m)
{
return n + m;
}
int a = 201, b = 202;
void f1(int n, int m)
{
n *= m;
}
static int c = 210, d = 212;
static void f2(int n, int m)
{
n /= m;
}
extern int h, k;
extern int f4(int n, int m);
int main()
{
int p, q, r;
p = c + d;
f2(-c, -2);
q = e + f;
r = h + k;
f4(-20, -22);
return 0;
}
|