C++核心准则​NR.4:不要坚持将每个类声明放在其自己的源文件中

2020-11-10 10:58:32 浏览数 (1)

NR.4: Don't insist on placing each class declaration in its own source file

NR.4:不要坚持将每个类声明放在其自己的源文件中

Reason(原因)

The resulting number of files from placing each class in its own file are hard to manage and can slow down compilation. Individual classes are rarely a good logical unit of maintenance and distribution.

将每个类放在自己的文件中而产生的文件数量很难管理,并且可能减慢编译速度。单个类很少是维护和分发的良好逻辑单元。

Example(示例)

代码语言:javascript复制
???
Alternative(代替选项)
  • Use namespaces containing logically cohesive sets of classes and functions. 使用包含逻辑上紧密结合的类和函数组合的命名空间。

原文链接

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nr4-dont-insist-on-placing-each-class-declaration-in-its-own-source-file

0 人点赞