/*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: object.cpp
* 作者:孙永
* 完成日期: 2013年4 月 12 日
* 版本号: v1.0
* 输入描述:无
* 问题描述:
* 程序输出:
*/
#include<iostream>
#include<string>
using namespace std;
class Box
{
public:
Box(int,int);
int volume(){return height*width*length;};
private:
static int height;
int width;
int length;
};
int Box::height=2;
Box::Box(int w,int l)
{
width=w;
length=l;
}
int main()
{
Box b(3,4);
cout<<"volume is "<<b.volume()<<endl;
return 0;
}
运行结果: