#include <iostream>
#include "Box.h"
Box::Box()
{
breadth=1;
height=1;
}
int Box::volume() const{return breadth*height;}
int Box::getBreadth() const {return breadth;}
int Box::getHeight() const {return height;}
int Box::compareVolume(const Box& otherBox) const
{
int vol1 =volume();
int vol2 =otherBox.volume();
return vol1>vol2 ? 1 : (vol1<vol2 ? -1 :0);
}
Box::Box(int abreadth,int aheight ):
breadth(abreadth) ,height(aheight)
{
//MID=Scounter++;
ManyBox=new Box* [breadth];
for(int i=0;i<breadth;i++)
ManyBox[i]=new Box [height];
}
Box::~Box()
{
for (int i=0;i<breadth;i++)
delete [] ManyBox[i];
delete [] ManyBox;
}
Box::Box (const Box& src)
{
CopyForm(src);
std::cout<<"调用复制构造函数!!!";
}
Box Box::operator=(const Box& src)
{
if(this==&src)
return (*this);
for(int i=0;i<breadth;i++)
{delete [] ManyBox[i];}
delete [] ManyBox;
CopyForm(src);
std::cout<<"调用重载赋值运算函数!!!";
return *this;
}
void Box::CopyForm(const Box& src)
{
breadth=src.breadth;
height=src.height;
ManyBox=new Box* [breadth];
for(int i=0;i<breadth;i++)
{
ManyBox[i]=new Box [height];
}
for(int i=0;i<breadth;i++)
for(int j=0;j<height;i++)
ManyBox[i][j]=src.ManyBox[i][j];
}
没有合适的资源?快使用搜索试试~ 我知道了~
不知是什么问题程序能运行
共3个文件
cpp:2个
h:1个
需积分: 0 1 下载量 64 浏览量
2008-12-13
12:29:39
上传
评论
收藏 1KB RAR 举报
温馨提示
烦您看看
资源详情
资源评论
资源推荐
收起资源包目录
.rar (3个子文件)
main.cpp 139B
Box.h 518B
Box.cpp 1KB
共 3 条
- 1
agrldu
- 粉丝: 7
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0