赞
踩
#include <iostream>
using namespace std;
class box
{
private:
float length;
float width;
float height;
public:
box(float a,float b,float c);
void volume();
};
box::box(float a,float b,float c)
{
length=a;
width=b;
height=c;
}
void box::volume()
{
cout<<"长方体的体积是:"<<length*width*height<<endl;
}
void main()
{
float a,b,c;
cout<<"请输入长方体的长:";
cin>>a;
cout<<"请输入长方体的宽:";
cin>>b;
cout<<"请输入长方体的高:";
cin>>c;
box chang(a,b,c);
chang.volume();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。