#include <iostream>
#include<string>
using namespace std;
class Box{
public:
Box(int w,int l):width(w),length(l){}
int volume(){return heigth*width*length;};
private:
static int heigth;
int width;
int length;
};
int Box::heigth=2;
int main()
{
Box b(3,4);
cout<<"volume is "<<b.volume()<<endl;
return 0;
}
运行结果: