gpt4 book ai didi

c++ - C++ 命名空间中静态函数的链接

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:16:07 25 4
gpt4 key购买 nike

在非全局命名空间中声明的静态函数的链接是什么?

例子:

namespace foo {
...
static void bar(int a) { }
}

这与在全局命名空间范围内声明的静态方法有什么不同吗?有人可以指出标准中的布局位置吗?

谢谢!

最佳答案

static 在命名空间级别的函数中使用时表示内部链接

具体引用自3.5 Program Linkage, paragraph 3:

A name having namespace scope (3.3.6) has internal linkage if it is the name of

  • a variable, function or function template that is explicitly declared static; or, [...]

关于c++ - C++ 命名空间中静态函数的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13615046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com