mirror of
https://github.com/zh-google-styleguide/zh-google-styleguide.git
synced 2025-02-19 20:50:10 +08:00
Merge pull request #14 from district10/master
fixed typo: inclues => includes
This commit is contained in:
commit
e4085bfb30
@ -53,7 +53,7 @@ As an exception, a function template that is explicitly instantiated for all rel
|
||||
|
||||
定义:
|
||||
|
||||
所谓「前向声明」(forward declaration)是类,函数和模板的纯粹声明,没伴随着其定义。代码中用到了哪些 symbols, 往往可以用其前向声明来代替对应的 ``#inclues``.
|
||||
所谓「前向声明」(forward declaration)是类,函数和模板的纯粹声明,没伴随着其定义。代码中用到了哪些 symbols, 往往可以用其前向声明来代替对应的 ``#includes``.
|
||||
|
||||
优点:
|
||||
|
||||
@ -195,4 +195,4 @@ C/C++ 函数参数分为输入参数, 输出参数, 和输入/输出参数三种
|
||||
#. Google 已经不再提倡 ``-inl.h`` 用法。
|
||||
#. 注意,前向声明的类是不完全类型(incomplete type),我们只能定义指向该类型的指针或引用,或者声明(但不能定义)以不完全类型作为参数或者返回类型的函数。毕竟编译器不知道不完全类型的定义,我们不能创建其类的任何对象,也不能声明成类内部的数据成员。
|
||||
#. 类内部的函数一般会自动内联。所以某函数一旦不需要内联,其定义就不要再放在头文件里,而是放到对应的 ``.cc`` 文件里。这样可以保持头文件的类相当精炼,也很好地贯彻了声明与定义分离的原则。
|
||||
#. 在``#include`` 中插入空行以分割相关头文件, C 库, C++ 库, 其他库的 `.h` 和本项目内的 `.h`.是个好习惯。
|
||||
#. 在 ``#include`` 中插入空行以分割相关头文件, C 库, C++ 库, 其他库的 ``.h`` 和本项目内的 ``.h`` 是个好习惯。
|
||||
|
Loading…
Reference in New Issue
Block a user