<bdo id='E4t3O'></bdo><ul id='E4t3O'></ul>
  1. <tfoot id='E4t3O'></tfoot>

    <small id='E4t3O'></small><noframes id='E4t3O'>

    <legend id='E4t3O'><style id='E4t3O'><dir id='E4t3O'><q id='E4t3O'></q></dir></style></legend>
    <i id='E4t3O'><tr id='E4t3O'><dt id='E4t3O'><q id='E4t3O'><span id='E4t3O'><b id='E4t3O'><form id='E4t3O'><ins id='E4t3O'></ins><ul id='E4t3O'></ul><sub id='E4t3O'></sub></form><legend id='E4t3O'></legend><bdo id='E4t3O'><pre id='E4t3O'><center id='E4t3O'></center></pre></bdo></b><th id='E4t3O'></th></span></q></dt></tr></i><div id='E4t3O'><tfoot id='E4t3O'></tfoot><dl id='E4t3O'><fieldset id='E4t3O'></fieldset></dl></div>

    1. 弃用 static 关键字...不再使用?

      时间:2023-12-03

    2. <i id='LIQyT'><tr id='LIQyT'><dt id='LIQyT'><q id='LIQyT'><span id='LIQyT'><b id='LIQyT'><form id='LIQyT'><ins id='LIQyT'></ins><ul id='LIQyT'></ul><sub id='LIQyT'></sub></form><legend id='LIQyT'></legend><bdo id='LIQyT'><pre id='LIQyT'><center id='LIQyT'></center></pre></bdo></b><th id='LIQyT'></th></span></q></dt></tr></i><div id='LIQyT'><tfoot id='LIQyT'></tfoot><dl id='LIQyT'><fieldset id='LIQyT'></fieldset></dl></div>

        <tfoot id='LIQyT'></tfoot>
            • <bdo id='LIQyT'></bdo><ul id='LIQyT'></ul>

              <small id='LIQyT'></small><noframes id='LIQyT'>

                  <tbody id='LIQyT'></tbody>
                <legend id='LIQyT'><style id='LIQyT'><dir id='LIQyT'><q id='LIQyT'></q></dir></style></legend>

              1. 本文介绍了弃用 static 关键字...不再使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 C++ 中,可以在翻译单元中使用 static 关键字来影响符号(变量或函数声明)的可见性.

                In C++ it is possible to use the static keyword within a translation unit to affect the visibility of a symbol (either variable or function declaration).

                在 n3092 中,这已被弃用:

                In n3092, this was deprecated:

                附件 D.2 [depr.static]
                在命名空间范围内声明对象时,不推荐使用 static 关键字(参见 3.3.6).

                Annex D.2 [depr.static]
                The use of the static keyword is deprecated when declaring objects in namespace scope (see 3.3.6).

                在 n3225 中,这已被删除.

                In n3225, this has been removed.

                我能找到的唯一一篇文章有点不正式.

                不过,它确实强调,为了与 C 兼容(以及将 C 程序编译为 C++ 的能力),弃用令人讨厌.但是,将 C 程序直接编译为 C++ 已经是一种令人沮丧的体验,因此我不确定是否值得考虑.

                It does underline though, that for compatibility with C (and the ability to compile C-programs as C++) the deprecation is annoying. However, compiling a C program directly as C++ can be a frustrating experience already, so I am unsure if it warrants consideration.

                有谁知道为什么要改?

                推荐答案

                在 C++ 标准核心语言缺陷报告和已接受的问题,修订版 94,1012.不赞成静态他们注意到:

                In C++ Standard Core Language Defect Reports and Accepted Issues, Revision 94 under 1012. Undeprecating static they note:

                尽管 7.3.1.1 [namespace.unnamed] 声明不推荐使用 static 关键字在命名空间范围内声明变量,因为未命名命名空间提供了更好的选择,但该功能不太可能在任何时候被删除可预见的未来.

                Although 7.3.1.1 [namespace.unnamed] states that the use of the static keyword for declaring variables in namespace scope is deprecated because the unnamed namespace provides a superior alternative, it is unlikely that the feature will be removed at any point in the foreseeable future.

                基本上这是说弃用 static 并没有真正的意义.它永远不会从 C++ 中删除.它仍然很有用,因为如果您只想声明具有内部链接的函数或对象,则不需要带有未命名 namespace 的样板代码.

                Basically this is saying that the deprecation of static doesn't really make sense. It won't ever be removed from C++. It's still useful because you don't need the boilerplate code you would need with unnamed namespace's if you just want to declare a function or object with internal linkage.

                这篇关于弃用 static 关键字...不再使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:C++ 静态虚拟成员? 下一篇:C++中的静态构造函数?我需要初始化私有静态对象

                相关文章

              2. <i id='LAJOB'><tr id='LAJOB'><dt id='LAJOB'><q id='LAJOB'><span id='LAJOB'><b id='LAJOB'><form id='LAJOB'><ins id='LAJOB'></ins><ul id='LAJOB'></ul><sub id='LAJOB'></sub></form><legend id='LAJOB'></legend><bdo id='LAJOB'><pre id='LAJOB'><center id='LAJOB'></center></pre></bdo></b><th id='LAJOB'></th></span></q></dt></tr></i><div id='LAJOB'><tfoot id='LAJOB'></tfoot><dl id='LAJOB'><fieldset id='LAJOB'></fieldset></dl></div>
              3. <small id='LAJOB'></small><noframes id='LAJOB'>

                <tfoot id='LAJOB'></tfoot>

                  • <bdo id='LAJOB'></bdo><ul id='LAJOB'></ul>

                    <legend id='LAJOB'><style id='LAJOB'><dir id='LAJOB'><q id='LAJOB'></q></dir></style></legend>