Example of static
class box { public: box (int v) : value(v) { boxCount++;
if (v == 0)
zeroCount++;
} private: static int boxCount = 0; static int zeroCount; };
// global initialization is separate from class
int box::zeroCount = 0;
Previous slide
Next slide
Back to first slide
View graphic version