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