class test {
public:
static int n;
test() { n++; };
~test() { n--; };
};
int test::n=0; //<----what is this step called? how can a class be declared as an integer?
int main() {
test a;
test b[5]; // I'm not sure what is going on here..is it an array?
test * c = new test;
cout << a.n << endl;
delete c;
cout << test::n << endl;
}
其次,輸出是7,6我不明白它是如何得到7,從哪裏?申報類整數
https://www.google.com/search?q=c%2B%2B+static+member+initialization&ie=utf-8&oe=utf-8&aq=t&rls=Palemoon:en-US&client=palemoon – user3528438