7.23构造函数

来源:互联网 发布:淘宝跨店凑单什么意思 编辑:程序博客网 时间:2024/06/05 15:50
/*构造函数*/
#include<iostream>
using namespace std;
class Box{
public:
Box
{
length=1;width=2;height=3;
}
void Show()
{
cout<<"length is :"<<length<<'\t'<<"width is :"<<width<<'\t'
<<"height is :"<<height<<endl;
}
private:
{
      float length,width,height;
};
int main()
{
Box box1;
cout<<"the information of box1 is :"<<endl;
box1.Show;
Box box2;
cout<<"the information of box2 is :"<<endl;
box2.Show;
return 0;
}
0 0