第3周实验报告4

来源:互联网 发布:2017ios福利软件 编辑:程序博客网 时间:2024/05/17 03:27
#include <iostream>using namespace std;class Box{public: void get_value(); void display();private: float length; float width; float heigth;};void Box::get_value(){ cout<<"请输入长方柱的长,宽,高: "<<endl; cin>>length; cin>>width; cin>>heigth;}void Box::display(){ cout<<"The value is: "<<length*width*heigth<<endl; cout<<"The areas is: "<<2*(length+width+heigth)<<endl;}int main(){ Box box1,box2,box3; box1.get_value(); cout<<"The box1 is: "; box1.display();    box2.get_value(); cout<<"The box2 is: "; box2.display();    box3.get_value(); cout<<"The box3 is: "; box3.display(); return 0;}


原创粉丝点击