類聲明的名稱的評價有這樣的代碼:秩序
#include <iostream>
const int c = 3;
struct A {
static int f() { return c; }
static const int c = 2;
};
int main() {
std::cout << A::f() << std::endl; // 2
return 0;
}
它是如何發生的變量c
定義內類A
在功能f
使用可變c
,而不是在全球範圍內,雖然定義首先聲明全局變量c
?