变量作用域
1 2 3 4 5 6 7 8 9 | int x = 5; int f() { int x = 3; //此x在f作用域中将覆盖全局的x { extern int x; //通过extern关键词引入文件作用域的x return x; //于是此作用域内的想是全局的x } } |
指针
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int foo(); int (*p)() = &foo; cout<<p(); p = foo; cout<<p(); p = *f; cout<<(*p)(); p = *******foo; cout<<p(); //上述代码,每一对对指针的赋值和调用都是等价的 |