今天我们主要讲解如何设计一个相对完整的类。
但是没有分文件编写。
这其中需要注意的是,我们在重载函数的时候,
在参数传递这块,在内存的消耗上面有所不同。
具体分析在程序中有注释部分需要认真看下。
/****************************************************
* brief : 设计一个立方体类
* author : shao
* date : 2020-02-25
* note : none
*
****************************************************/
#include <iostream>
using namespace std;
class Cube{
private:
int cube_length;
int cube_width;
int cube_height;
public:
int getCubeLength(void)
{
return cube_length;
}
int getCubeWidth(void)
{
return cube_width;
}
int getCubeHeight(void)
{
return cube_height;
}
void setCubeLength(int length)
{
cube_length = length;
}
void setCubeWidth(int width)
{
cube_width = width;
}
void setCubeHeight(int height)
{
cube_height = height;
}
void getCubeVolume(void)
{
int ret1;
ret1 = cube_length * cube_width * cube_height;
cout << "Cube volum