用C++语言“定义并实现一个矩形类,有长、宽两个属性,用成员函数计算矩形的面积”。(编出程序拿分)

[复制链接]
查看11 | 回复2 | 2008-12-23 09:10:36 | 显示全部楼层 |阅读模式
只要求用C++语言实现这个小程序

回复

使用道具 举报

千问 | 2008-12-23 09:10:36 | 显示全部楼层
我是试试哈 #include "iostream" using namespace std; class rectangle//定义矩形类 { public: rectangle(float longth,float weight)//构造函数 { itslongth=longth;itsweight=weight; } float getArea(){return itslongth*itsweight;};//计算矩形面积 private: float itslongth,itsweight;//定义长宽属性 }; int main() { rectangle rec1(5...
回复

使用道具 举报

千问 | 2008-12-23 09:10:36 | 显示全部楼层
#includeusing namespace std;class graph{protected:
float high,wide;public:
graph();
graph(float h,float w)
{
high=h;wide=w;cout #include #include "rectangle.h" using namespace std; int main(int argc, char *argv[]) { Rectangle rect1; rect1.setL...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行