#include <iostream>
using namespace std;
class Desk{
public:
Desk();//声明一个无参的构造函数
/*声明一个有参的构造函数,并用参数的初始化列表对数据成员初始化*/
Desk(int h,int w,int l):height(h),width(w),length(l){}
int volume();
private:
int height,width,length;
};
Desk::Desk(){//定义无参的构造函数
height=2;
width=3;
length=4;
}
int Desk::volume(){
return height*width*length;
}
int main(){
Desk desk1;//不指定实参
cout<<"desk1's volume: "<<desk1.volume()<<endl;
Desk desk2(1,5,5);//指定实参
cout<<"desk2's volume: "<<desk2.volume()<<endl;
return 0;
}