⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xt8-6-2.cpp

📁 谭浩强所著C++课后的部分习题集解答(c++)
💻 CPP
字号:
#include <iostream>
using namespace std;
class Box
{public:
  void get_value();
  void volume();
  void display();
 public:
  float lengh;
  float width;
  float height;
  float vol;
  };

void Box::get_value()
{ cout<<"please input lengh, width,height:";
  cin>>lengh;
  cin>>width;
  cin>>height;
}

void Box::volume()
{ vol=lengh*width*height;}

void Box::display()
{ cout<<vol<<endl;}

int main()
{Box box1,box2,box3;
 box1.get_value();
 box1.volume();
 cout<<"volmue of bax1 is ";
 box1.display();
 box2.get_value();
 box2.volume();
 cout<<"volmue of bax2 is ";
 box2.display();
 box3.get_value();
 box3.volume();
 cout<<"volmue of bax3 is ";
 box3.display();
 return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -