ch16_06.cpp

来自「在文件中含有大量基础C program code以公初学者参考」· C++ 代码 · 共 37 行

CPP
37
字号
#include <iostream>
using namespace std;
template <class type>
class cube
{
  private:
        type length;
        type width;
        type height;
        type volume;
  public:
        void set_length(type len)
        {
            length = len;
        }
        void set_width(type wid)
        {
            width = wid;
        }
        void set_height(type hei)
        {
            height = hei;
        }
        void calculate();
        void show_volume();
};
//---------------------------------
template <class type>
void cube<type>::calculate()
{
    volume = length*width*height;
}
//---------------------------------
template <class type>
void cube<type>::show_volume()
{
    cout<<"

⌨️ 快捷键说明

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