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

        <bdo id='tUd0H'></bdo><ul id='tUd0H'></ul>

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

        <tfoot id='tUd0H'></tfoot>
      1. <legend id='tUd0H'><style id='tUd0H'><dir id='tUd0H'><q id='tUd0H'></q></dir></style></legend>

        为什么编译器支持冗余范围限定,是否合法?

        时间:2023-10-17
              <tbody id='ylRYm'></tbody>
            <tfoot id='ylRYm'></tfoot>

          • <small id='ylRYm'></small><noframes id='ylRYm'>

              <i id='ylRYm'><tr id='ylRYm'><dt id='ylRYm'><q id='ylRYm'><span id='ylRYm'><b id='ylRYm'><form id='ylRYm'><ins id='ylRYm'></ins><ul id='ylRYm'></ul><sub id='ylRYm'></sub></form><legend id='ylRYm'></legend><bdo id='ylRYm'><pre id='ylRYm'><center id='ylRYm'></center></pre></bdo></b><th id='ylRYm'></th></span></q></dt></tr></i><div id='ylRYm'><tfoot id='ylRYm'></tfoot><dl id='ylRYm'><fieldset id='ylRYm'></fieldset></dl></div>
              <legend id='ylRYm'><style id='ylRYm'><dir id='ylRYm'><q id='ylRYm'></q></dir></style></legend>
                • <bdo id='ylRYm'></bdo><ul id='ylRYm'></ul>
                  本文介绍了为什么编译器支持冗余范围限定,是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在两个编译器上进行了测试,很惊讶地发现它们都支持以下定义而毫无怨言:

                  I tested on two compilers, and was surprised to see both support the following definition without complaint:

                  class A {
                    A();
                  };
                  
                  A::A::A() {}
                     ^^^
                  

                  请注意,这也适用于方法,尽管在声明过度限定时会被标记.

                  Note that this also succeeds for methods, although it is flagged when the declaration is over-qualified.

                  问题:

                  • 这是一个有效的 C++ 程序吗?
                  • 如果是这样,它有什么用途 - 还是仅仅是副产品?

                  更新详情:

                  如果最初的问题不清楚或太短:我很好奇为什么在定义中允许使用多余的资格(重点也在上面添加).

                  In case the original question was not clear or too short: I'm curious why redundant qualifications are permitted on the definition (emphasis also added above).

                  Clang 和 Apple 的 GCC 4.2 + LLVM 是编译器

                  推荐答案

                  Yes, it's allowed (§9/2):

                  Yes, it's allowed (§9/2):

                  class-name 也插入到类本身的作用域中;这被称为注入类名.出于访问检查的目的,注入的类名被视为公共成员名.

                  The class-name is also inserted into the scope of the class itself; this is known as the injected-class-name. For purposes of access checking, the injected-class-name is treated as if it were a public member name.

                  有关导致类名注入的推理的信息,您可能需要阅读N0444.

                  For information about the reasoning that lead to class name inject, you might want to read N0444.

                  这篇关于为什么编译器支持冗余范围限定,是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:什么时候对象“超出范围"? 下一篇:有没有办法在 C++ 中访问外部作用域中的局部变量?

                  相关文章

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

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