#include<iostream.h>
class Rectangle
{
public:
Rectangle(int x,int y)
{
length=x;
width=y;
}
~Rectangle(){}
int GetArea()
{
return length*width;
}
private:
int length,width;
};
void main()
{
int l,w,a;
cout<<"please input the length and the width:"<<endl;
cin>>l>>w;
Rectangle shape(l,w);
cout<<"the area of the shap is :"<<endl;
a=shape.GetArea();
cout<<a<<endl;
}
温馨提示:答案为网友推荐,仅供参考