double b, double h) : length(l), breadth(b), height(h) { ++objectCount; } ~Box() { --objectCount; } static int getObjectCount() { return objectCount; } private: double length, height, breadth; static int objectCount; }; //---------------------------------------------------------------- // box.cpp int Box::objectCount = 0; Вызов функции:
Box::getObjectCount()