c++_编码规范

好的代码通常源于好的规范约束


Google 编码规范 图文解释

图来源于 : https://blog.csdn.net/voidccc/article/details/37599203


Google 翻译文档

http://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/contents/


我的编码规范

类 class

CDog : 以 C 开头表示 class

  • private 成员: _name : 以 _ 开头,单词首字母小写
  • public、protected 成员: name , 单词首字母小写
  • private 函数 : _calcuFunc() : 以 _ 开头,单词首字母小写
  • public 、protected 函数 : GetName(),单词首字母大写
  • static 成员 : ClsName : 单词首字母大写
  • 函数形参: (string name, int age)

结构体 struct

SCat : 以 S 开头表示 struct

枚举 enum

ENetStatus : 以 E 开头表示 enum

const 变量

kActorLimit : 以 k 开头

全局变量

gGame : 以 g 开头表示 global