没有合适的资源?快使用搜索试试~ 我知道了~
推荐下载C- c++-头文件中的静态函数,是什么意思?.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 121 浏览量
2022-10-26
00:36:00
上传
评论
收藏 11KB DOCX 举报
温馨提示
试读
1页
。。。
资源推荐
资源详情
资源评论
C/ c++:头文件中的静态函数,是什么意思?[英]C/C++: Static function in header
file, what does it mean? I know what it means when static function is declared in
source
file. I am reading some code, found that static function in header files could be invoke in
我知道在源文件中声明静态函数意味着什么。我正在阅读一些代码,发现头文件
中的静态函数可以在其他文件中调用。
55
Is the function defined in the header file? So that the actual code is given directly in
the
函数是否在头文件中定义?因此实际的代码是直接在函数中给出的,像这样
static int addTwo(int x) return x + 2; Then that’jsust a way of providing a useful
function to many different C files. Each C file that includes the header will get its own
definition that it can call. This of course wastes memory, and is (in my opinion) a quite
ugly thing to be doing, since having executable code in a header is generally not a
good
idea.
然后,这只是为许多不同的 C 文件提供有用函数的一种方式。包含头的每个 C 文
件都将获得它可以调用的自己的定义。这当然会浪费内存,而且(在我看来)是一件
非常糟糕的事情,因为在头中有可执行代码通常不是一个好主意。
Remember that #include:ing a header basically just pastes the contents of the
header
(and any other headers included by it) into the C file as seen by the compiler. The
compiler
never knows that the one particular function definition came from a header file.
记住#include:ing 头文件基本上就是将头文件的内容(以及它包含的任何其他头文
件)粘贴到 C 文件中,就像编译器看到的那样。编译器永远不会知道一个特定的函数
定义来自头文件。
资源评论
G11176593
- 粉丝: 6585
- 资源: 3万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功