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

满意答案

02ae427d08e371d7e90d5b995e828d6d.png

woshizdz

2013.04.27

02ae427d08e371d7e90d5b995e828d6d.png

采纳率:46%    等级:13

已帮助:14778人

//main.cpp文件内容

#include

#include

#include "rectangle.h"

using namespace std;

int main(int argc, char *argv[])

{

Rectangle rect1;

rect1.setLengthAndWidth();

rect1.showArea();

system("PAUSE");

return 0;

}

//Rectangle.h文件内容

#include

using namespace std;

class Rectangle

{

public:

void showArea();

void setLengthAndWidth();

private:

float length,width;

}

//rectangle.cpp文件内容

#include

#include"rectangle.h"

using namespace std;

void Rectangle::showArea()

{

cout<

}

void Rectangle::setLengthAndWidth()

{

do{

cout<

cin>>length>>width;

if (length<0||width<0) cout<

}while(length<0||width<0);

}

//运行通过的,你也可以把这三部分放一个文件里。

//其实并不长,只是为了可读性增加了空行,你可以去掉。

//而且如果放一个文件里可以去掉重复声明的头文件。

//但是为了更标准一些,建议你还是分三个文件放

60分享举报

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值