#include <iostream>
using namespace std;
class Rect
{
private:
int width;
int heigth;
public:
//void init(int width,int heigth);
void show(int width,int heigth);
void changed(int width,int heigth);
};
void Rect::show(int width,int heigth)
{
int a=this->width*this->heigth;
int b=(this->width+this->heigth)*2;
cout << "矩形面积为:" << a << endl;
cout << "矩形周长为:" << b << endl;
}
void Rect::changed(int width, int heigth)
{
cout << "请输入宽度" << endl;
cin >> width;
cout << "w=" << width << endl;
cout << "请输入长度" << endl;
cin >> heigth;
cout << "h=" << heigth << endl;
cout << "数据输入成功" << endl;
this->width=width;
this->heigth=heigth;
}
int main()
{
Rect r1;
int width=0;
int heigth=0;
r1.changed(width,heigth);
r1.show( width, heigth);
return 0;
}
11/29
最新推荐文章于 2024-07-25 23:26:35 发布