参考
中文版地址:
https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/headers/
总结
| 类型 | 示例 |
|---|---|
| 类名、函数名 | 大驼峰 |
| 文件名 | my_tiny_stl.cc my_tiny_stl.h |
| 头文件的宏 | MY_TINY_STL_H_ MACRO |
| 变量名 public数据成员 私有成员 | my_vector abc_de abc_de_ |
| 常量 | k+大驼峰,kConstData |
| namespace | std, mytinystl |
- 类遵循声明和定义分离的原则
class decleration
#ifndef HEAD_H_
#define HEAD_H_
/* TODO */
class NewClass
{
public:
static int static_int_val;
float float_val;
void MemFunc1();
};
// aux func
void AuxFunc();
#endif
class definition
#include"class_decleration.h"
#c head
#c++ head
#otherhead
#this project head
int NewClass::static_int_val = 0;
float NewClass::float_val = 3.14;
void NewClass::MemFunc1()
{
// TODO
}
本文档总结了Google C++风格指南的关键部分,包括命名约定、头文件宏使用、类声明与定义分离等最佳实践。对于C++开发者来说,遵循这些规范有助于提高代码的可读性和一致性。
1189

被折叠的 条评论
为什么被折叠?



