#include using namespace std; class Rectangle { private: int width, height; public: static int rectangles; Rectangle(int w, int h); Rectangle(int s); int getWidth() const; int getHeight() const; void setWidth(int w); void setHeight(int h); static int getRectanglesNumber(); }; int Rectangle::rectangles = 0; Rectangle::Rectangle(int w, int h) { width = w; height = h; rectangles++; } Rectangle::Rectangle(int s) { width = height = s; rectangles++; } int Rectangle::getWidth() const { return width;} int Rectangle::getHeight() const { return height;} void Rectangle::setWidth(int w) { width = w; } void Rectangle::setHeight(int h) { height = h; } static int getRectanglesNumber() { //width++; // this is not allowed. return Rectangle::rectangles; } int main() { Rectangle rect1(3,4); Rectangle rect2(5); cout << "Number of rectangles is " << getRectanglesNumber() << endl; cout << "Number of rectangles is " << Rectangle::rectangles << endl; cout << "Number of rectangles is " << rect1.rectangles << endl; }