C++ 规范 自己参考

来源:互联网 发布:mac抓包工具charles 编辑:程序博客网 时间:2024/06/09 14:27
01./* 文件名称: MyClass.h  02. * 摘    要:  03. *  04. * 当前版本:  05. * 作    者:  06. * 完成日期:  07. *  08. * 更新说明:  09. *  10. */  11.   12. #ifndef MYCLASS_H_  13. #define MYCLASS_H_  14.   15. #include <string>            //标准库头文件  16.   17. #include "other.h"         //自定义头文件  18.   19. int  g_initValue;          /全局变量以g_开头。  20. const  int  MAX = 100;     //常量应该全部大写。  21.   22. struct MyStruct            //全局结构体声明  23. {  24.    int num;  25.    string name;  26.    string address  27. };  28.   29. void AddNumber(void);          //函数名应使用动词或动词+名词。首字母大写,用大写隔开。无参数的要用void填充。  30.   31. class MyClass                  //类声明,类名首字母大写,用大写隔开。  32. {  33.    public:  34.        int AddArea(int width, int height);       35.  36.    private:                        //建议将变量声明放在后面,以“行为”为中心,用户关心的是接口。  37.        enum{SIZE = 100, SIZET = 200};  //枚举常量  38.        int  m_width;             39.        int  m_height;              //类的数据成员以m_开头。避免数据成员与成员函数参数同名。  40.        static int s_initValue;     //静态变量用s_开头。  41.          42. };  43.  44. #endif</span>