Problem Description
定义并实现一个矩形类,有长、宽两个属性,由成员函数area计算矩形的面积。
下面的程序不完整,请完善它:
#include <iostream>
using namespace std;
class rectangle{
//你的代码将被嵌在这里
};
int main()
{
rectangle r(3,4);
cout<<r.area();
return 0;
}Sample Output
12
public:
rectangle(int x, int y)
{
m_X = x;
m_Y = y;
}
int area()
{
return m_X * m_Y;
}
int m_X;
int m_Y;