p262 8.6 求长方体的体积.cpp

来自「谭浩强 《C++ 程序设计》第三版的部分课后练习题源码」· C++ 代码 · 共 41 行

CPP
41
字号
#include<iostream>
using namespace std;
class box
{
      private:
              float length;
              float width;
              float height;
      public:
             void set_value();
             void cubage();
            
};

void box::set_value()
{
     cout<<"please input the length width and height: ";
     cin>>length>>width>>height;
     
}

void box::cubage()
{
     float cube;
     cube=length*width*height;
     cout<<"the cubage of the cube is "<<cube<<endl;
     
     
}

int main()
{    box cube;
     cube.set_value();
     cube.cubage();
     system("pause");
     return 0;
    
    
    
    }

⌨️ 快捷键说明

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