/*
* Copyright (c) 2011, 烟台大学计算机学院
* All rights reserved.
* 作 者:王筱菀
* 完成日期:2013 年4月12月
* 版 本 号:v1.0
* 输入描述:
* 问题描述:略
#include <iostream>
#include <string>
using namespace std;
class Box
{
public:
Box(int h,int w,int l):height(h),width(w),length(l){}
int volume( ){return height*width*length;};
private:
static int height; //静态的数据成员
int width;
int length;
};
int main()
{
Box b(2,3,4);
cout<<"volume is "<<b.volume()<<endl;
return 0;
}
*/
#include <iostream>
#include <string>
using namespace std;
class Box
{
public:
Box(int w,int l):width(w),length(l){}
int volume( ){return height*width*length;};
private:
static int height; //静态的数据成员
int width;
int length;
};
int Box::height=2;
int main()
{
Box b(3,4);
cout<<"volume is "<<b.volume()<<endl;
return 0;
}
2013-4-12.1~程序改错
最新推荐文章于 2024-04-25 21:58:19 发布