C++编程命名规范
来源:互联网 发布:激光打标机软件配套 编辑:程序博客网 时间:2024/06/06 10:03
根据多年工作经验和其它命名规范整理而成,个人感觉比较规范的标准,现应用于我的开发团队。
c++文件应以.cpp,头文件以.h结尾,文件名全部小写,文件名和类名相同。
举例:
publictools.h
publictools.cpp
类型包括:类(class)、结构体(struct)、类型定义(typedef)、枚举(enum)等。
类型名称每个单词首字母大写。
举例:
类(class):
class TestClass
{
};
结构体(struct):
struct TestStruct
{
};
类型定义(typedef):
typedef struct TestType
{
};
枚举(enum):
enum TestEnum
{
};
普通变量首字母小写,成员变量以_结尾,函数参数以_开头。全局变量g_开头,静态变量s_开头。
举例:
普通变量:
int index;
char type;
string name;
成员变量:
int index_;
函数参数
void SetIndex(int _index)
{
};
全局变量:
int g_count;
静态变量
int s_number;
全大写,单词间用_分开。
举例:
const string MAX_FILENAME255;
首字母大写,取值与设值函数与变量名匹配。
举例:
int index_;
int GetIndex()
{
returnindex_;
};
void SetIndex(int _index)
{
index_ =_index;
};
全小写字母。
举例:
namespace myNamespace
{
};
首单词全写,次单词首字母大写。
举例:
struct TestStruct
{
int number,
string studentName
};
enum TestEnum
{
errorIn,
errorOut
};
全大写,单词间用_分开。
举例:
#define PI_RAUD3.14159265
全大写。
举例:
#ifndef FOO_BAR_BAZ_H_
#define FOO_BAR_BAZ_H_
...
#endif // FOO_BAR_BAZ_H_;
- C语言编程规范4: 命名规则
- C#(编程规范) -.NET命名规范中文版
- 编程规范-1命名规范
- Java编程命名规范
- Java编程命名规范
- 编程命名规范
- C#编程命名规范
- C++编程命名规范
- C++编程 命名规范
- JAVA编程规范--命名
- C++编程命名规范
- C#编程命名规范
- C++编程命名规范
- C++编程命名规范
- 编程命名规范
- C++编程命名规范
- 编程命名规范
- C#编程命名规范
- 剑指offer--矩形覆盖
- 记录自己今天理解的 equals 方法
- 《coredump问题原理探究》Linux x86版7.4节List coredump例子
- 实验楼的laravel 4.2 blog 教程(五)
- 第七周项目三——第8、9章的知识点思维导图
- C++编程命名规范
- Java核心技术I——基础点拾掇(第三章)
- sql
- Crypto LAB
- 对"对象的多个属性"进行匹配搜索"对象数组"的算法
- CodeCademy | Python | 7. Function
- 2014上海全国邀请赛——题目重现 4.24
- oracle执行计划详解
- Windows串口通信相关API函数