一道c++题目,急急急,给好评!!!

2025-04-29 15:18:21
推荐回答(1个)
回答1:

#include
using namespace std;

class Rectange{

public :

  Rectange(){
setCenter(0,0);
this->height = 10;
this->width = 10;
  }
  Rectange(int width,int height,int x,int y ){
                this->width = width;
                this->height = height;
                setCenter(x,y);
  }
  int getArea(){
return this->height * this->width;
  }
  void setCenter(int x,int y){
this->m_x = x;
this->m_y = y;
  }

private :
int m_x,m_y;
int width,height;
};




int main() {

    Rectange  rect1 = Rectange();
    cout<
    Rectange rect2 = Rectange(20,20,0,0); 
    cout< return 0;

}