C++的类:

[复制链接]
查看11 | 回复2 | 2010-5-30 13:01:10 | 显示全部楼层 |阅读模式
定义一个box的类,在该类定义中包括数据成员,length,width,height.成员函数:构造函数box设置长,宽,高三个数据;函数volume计算并输出盒子的体积 。从键盘输出长,宽,高,并求盒子的体积

回复

使用道具 举报

千问 | 2010-5-30 13:01:10 | 显示全部楼层
#includeusing namespace std;class box{
private:
float length,width,heigh;
public:
box(float len,float wid,float hei){
length = len;
width = wid;
heigh = hei;
}
float volume(){
return length
回复

使用道具 举报

千问 | 2010-5-30 13:01:10 | 显示全部楼层
#includeclass box{ int length; int width; int height;public: box():bength(0),width(0),height(0){} box(int i=1;int z=1;int f=1):length(i),width(z
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行