#include <iostream>
using namespace std;
struct Box
{
public:
Box(int,int,int); //声明带参数的构造函数
int volume();
private:
int length;
int width;
int height;
};
Box::Box(int len,int w,int h)
{
height=h;
width=w;
length=len;
}
int Box::volume()
{
return (length*width*height);
}
int main()
{
Box b1(10,10,10);
cout<<"volume="<<b1.volume()<<endl;
return 0;
}
using namespace std;
struct Box
{
public:
Box(int,int,int); //声明带参数的构造函数
int volume();
private:
int length;
int width;
int height;
};
Box::Box(int len,int w,int h)
{
height=h;
width=w;
length=len;
}
int Box::volume()
{
return (length*width*height);
}
int main()
{
Box b1(10,10,10);
cout<<"volume="<<b1.volume()<<endl;
return 0;
}