Q:

C++ static member, a little confused here

    //static member in classes
#include <iostream>
using namespace std;

class CDummy {
public:
    static int n;
    CDummy() {n++;};
    ~CDummy(){n--;};
};

int CDummy::n =0;

int main(){
    CDummy a;
    CDummy b[5];
    CDummy *c = new CDummy;
    cout << a.n << endl;
    delete c;
    cout << CDummy::n << endl;
    return 0;
}

The result is  7, 6.
Can anybody explain it for me?
and I don't understand this "CDummy b[5];". People never use syntax like this in C, right? what is this here?
Thank you!

A:

CDummy b[5];

This declares an array of five CDummy objects.  It ends up calling the CDummy default constructor five times (once for each object in the array).
You create seven CDummy objects:  a, five in the array b, and the one pointed to by c.  n then has a value of 7.  Then you destroy one CDummy object (the one pointed to by c) and n has a value of 6.  The remaining six CDummy objects are destroyed when they go out of scope when the main function returns.

