【write函数】c 程序包括计算立方体体积等函数writeaprogram...

发布时间:2021-04-02 14:15:38

c++程序,包括计算立方体体积等函数write a program that the class Cube is defined with the properties Length.Width.Height.The class includes the following definition:a.Two constructors,a copy construcors and destructor;b.A member function of caculating the volume of Cube;c.A member function of displaying the properties;d.A member function of moving a Cube;e.A member function of modify the properties of Cube;求大神

网友回答

【答案】 #include
  class Cube
  {
  public:
  //Constructors and Destructor
  Cube();
  Cube(int Height,int Width,int Length);
  Cube(const Cube&);
  Cube();
  public:
  //Main Member Function
  enum MODIFYTYPE{WIDTH,LENGTH,HEIGHT};
  void Volume();
  void ShowProper();
  void Move();
  void Modify(int toModify,MODIFYTYPE type);
  private:
  //properties
  unsigned int m_height;
  unsigned int m_width;
  unsigned int m_length;
  };
  Cube::Cube()
  {
  m_height = m_width = m_length = 0;
  }
  Cube::Cube(int Height,int Width,int Length)
  {
  m_height = Height;
  m_width = Width;
  m_length = Length;
  }
  Cube::Cube(const Cube& tC)
  {
  m_height = tC.m_height;
  m_width = tC.m_width;
  m_length = tC.m_length;
  }
  Cube::Cube()
  {
  m_height = m_width = m_length = 0;
  }
  void Cube::Volume()
  {
  if (m_height
以上问题属网友观点,不代表本站立场,仅供参考!