且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在哪里放置包含语句、标题或来源?

更新时间:2023-11-29 22:02:22

只有在 header 本身需要的时候才将 include 放在 header 中.

Only put includes in a header if the header itself needs them.

例子:

  • 您的函数返回类型 size_t.然后#include <stddef.h>header文件中.
  • 您的函数使用 strlen.然后在source文件中#include <string.h>.
  • Your function returns type size_t. Then #include <stddef.h> in the header file.
  • Your function uses strlen. Then #include <string.h> in the source file.