#includeiostream
usingnamespacestd;
classBox
{
public:
Box(int,int,int);
intvolume();
private:
intheight;
intwidth;
intlength;
};
Box::Box(inth,intw,intl)
{
height=h;
width=w;
length=l;
}
intBox::volume()
{
intmid;
mid=length*width*length;
returnmid;
}
intmain()
{
Boxbox1(12,25,30);
cout\"盒子1的体积是:\"box1.volume()endl;
Boxbox2(15,30,21);
cout\"盒子2的体积是:\"box2.volume()endl;
return0;
}
|