<legend id='eOptF'><style id='eOptF'><dir id='eOptF'><q id='eOptF'></q></dir></style></legend>
      <bdo id='eOptF'></bdo><ul id='eOptF'></ul>

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

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

      <tfoot id='eOptF'></tfoot>
    2. 构造函数初始化列表求值顺序

      时间:2023-09-19

    3. <small id='Vb22H'></small><noframes id='Vb22H'>

        <tfoot id='Vb22H'></tfoot>
            <legend id='Vb22H'><style id='Vb22H'><dir id='Vb22H'><q id='Vb22H'></q></dir></style></legend>

              • <bdo id='Vb22H'></bdo><ul id='Vb22H'></ul>
                <i id='Vb22H'><tr id='Vb22H'><dt id='Vb22H'><q id='Vb22H'><span id='Vb22H'><b id='Vb22H'><form id='Vb22H'><ins id='Vb22H'></ins><ul id='Vb22H'></ul><sub id='Vb22H'></sub></form><legend id='Vb22H'></legend><bdo id='Vb22H'><pre id='Vb22H'><center id='Vb22H'></center></pre></bdo></b><th id='Vb22H'></th></span></q></dt></tr></i><div id='Vb22H'><tfoot id='Vb22H'></tfoot><dl id='Vb22H'><fieldset id='Vb22H'></fieldset></dl></div>
                  <tbody id='Vb22H'></tbody>
              • 本文介绍了构造函数初始化列表求值顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个带有一些参数的构造函数.我曾假设它们是按照列出的顺序构建的,但在一种情况下,它们似乎是反向构建的,导致中止.当我反转参数时,程序停止中止.这是我正在使用的语法示例.问题是,在这种情况下, a_ 需要在 b_ 之前初始化.你能保证施工顺序吗?

                I have a constructor that takes some arguments. I had assumed that they were constructed in the order listed, but in one case it appears they were being constructed in reverse resulting in an abort. When I reversed the arguments the program stopped aborting. This is an example of the syntax I'm using. The thing is, a_ needs to be initialized before b_ in this case. Can you guarantee the order of construction?

                例如

                class A
                {
                  public:
                    A(OtherClass o, string x, int y) :
                      a_(o), b_(a_, x, y) { }
                
                    OtherClass a_;
                    AnotherClass b_;
                };
                

                推荐答案

                取决于类中成员变量声明的顺序.所以 a_ 将是第一个,然后 b_ 将是您示例中的第二个.

                It depends on the order of member variable declaration in the class. So a_ will be the first one, then b_ will be the second one in your example.

                这篇关于构造函数初始化列表求值顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:模拟鼠标点击而不移动光标 下一篇:使用 __gnu_mcount_nc 捕获函数退出时间

                相关文章

                最新文章

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

                  1. <tfoot id='cRlQE'></tfoot>

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

                  4. <small id='cRlQE'></small><noframes id='cRlQE'>