job1.cpp
#include <iostream>
#include "Rectangle.h"
using namespace std;
int main(){
double width,height;
Rectangle r1;
cout << "输出第一个缺省的矩形对象的信息:"<<endl;
r1.display();
cout << "请输入矩形的宽度和高度:";
cin >> width >> height;
Rectangle r2(width , height);
cout << "输出第二个缺省的矩形对象的信息:"<<endl;
r2.display();
return 0;
}
Rectangle.cpp
//
// Created by 63400 on 2021/10/14.
//
#include <iostream>
#include "Rectangle.h"
using namespace std;
int Rectangle::count = 0;
Rectangle::Rectangle(double width, double height) {
this->width = width;
this->height = height;
count++;
}
Rectangle::~Rectangle(){
count--;
}
double Rectangle::getWidth(){
return width;
}
double Rectangle::getHeight(){
return height;
}
void Rectangle::setWidth(double width){
thi