<tfoot id='jjXCv'></tfoot>

  • <legend id='jjXCv'><style id='jjXCv'><dir id='jjXCv'><q id='jjXCv'></q></dir></style></legend>

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

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

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

        如何强制执行“覆盖"关键字?

        时间:2023-10-06

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

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

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

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

                <tfoot id='qeaPo'></tfoot>
                  <tbody id='qeaPo'></tbody>

                  本文介绍了如何强制执行“覆盖"关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有什么方法可以强制在 Visual C++ 2012 中使用 C++11 override 关键字?

                  Is there any way to enforce the usage of the C++11 override keyword in Visual C++ 2012?

                  (即如果我忘记说override,那么我想收到警告/错误.)

                  (i.e. if I forget to say override, then I want to get a warning/error.)

                  推荐答案

                  C++11 几乎有你想要的.

                  C++11 almost had what you want.

                  最初 override 关键字是更大提案的一部分 (N2928),其中还包括强制使用的能力:

                  Originally the override keyword was part of a larger proposal (N2928) which also included the ability to enforce its usage:

                  class A
                  {
                    virtual void f();
                  };
                  
                  class B [[base_check]] : public A
                  {
                      void f();  // error!
                  };
                  
                  class C [[base_check]] : public A
                  {
                    void f [[override]] ();  // OK
                  };
                  

                  base_check 属性会使在不使用 override 关键字的情况下覆盖虚函数时出错.

                  The base_check attribute would make it an error to override a virtual function without using the override keyword.

                  还有一个 hiding 属性,表示函数隐藏基类中的函数.如果使用了 base_check 并且一个函数在基类中隐藏了一个函数而不使用 hiding,那就是一个错误.

                  There was also a hiding attribute which says a function hides functions in the base class. If base_check is used and a function hides one from the base class without using hiding it's an error.

                  但是大部分提案都被放弃了,只有 final 和 override 特性被保留下来,作为具有特殊含义的标识符"而不是属性.

                  But most of the proposal was dropped and only the final and override features were kept, as "identifiers with special meaning" rather than attributes.

                  这篇关于如何强制执行“覆盖"关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否可以强制不内联函数? 下一篇:_chkstk() 函数的目的是什么?

                  相关文章

                  最新文章

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

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

                    <tfoot id='Lnis7'></tfoot>

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

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