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

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

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

        在 new (c++) 的构造函数调用中不使用括号

        Not using parentheses in constructor call with new (c++)(在 new (c++) 的构造函数调用中不使用括号)

          <tbody id='fakpR'></tbody>
              <bdo id='fakpR'></bdo><ul id='fakpR'></ul>

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

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

                1. <tfoot id='fakpR'></tfoot>
                  <i id='fakpR'><tr id='fakpR'><dt id='fakpR'><q id='fakpR'><span id='fakpR'><b id='fakpR'><form id='fakpR'><ins id='fakpR'></ins><ul id='fakpR'></ul><sub id='fakpR'></sub></form><legend id='fakpR'></legend><bdo id='fakpR'><pre id='fakpR'><center id='fakpR'></center></pre></bdo></b><th id='fakpR'></th></span></q></dt></tr></i><div id='fakpR'><tfoot id='fakpR'></tfoot><dl id='fakpR'><fieldset id='fakpR'></fieldset></dl></div>
                  本文介绍了在 new (c++) 的构造函数调用中不使用括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能的重复:
                  在类型名后面加括号make和新的有区别吗?

                  所以我的主要内容:

                  Class* pC = new Class;
                  

                  它的工作原理

                  Class* pC = new Class();
                  

                  我今天才意识到我省略了括号(所以我在某种程度上被最烦人的解析的相反"击中了).

                  I realized just today that I had omitted the parentheses (so I was hit by the "opposite" of the most vexing parse in a way).

                  我的问题:这两种形式是否等价?

                  My question: Are these two forms equivalent ?

                  推荐答案

                  如果类定义了默认构造函数,则两者是等价的;该对象将通过调用该构造函数来创建.

                  If the class has a default constructor defined, then both are equivalent; the object will be created by calling that constructor.

                  如果类只有一个隐式的默认构造函数,那就有区别了.第一个将使 POD 类型的任何成员未初始化;第二个将值初始化它们(即将它们设置为零).

                  If the class only has an implicit default constructor, then there is a difference. The first will leave any members of POD type uninitialised; the second will value-initialise them (i.e. set them to zero).

                  这篇关于在 new (c++) 的构造函数调用中不使用括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)
                      <tfoot id='7QN1y'></tfoot>
                        <bdo id='7QN1y'></bdo><ul id='7QN1y'></ul>
                          <tbody id='7QN1y'></tbody>
                      • <i id='7QN1y'><tr id='7QN1y'><dt id='7QN1y'><q id='7QN1y'><span id='7QN1y'><b id='7QN1y'><form id='7QN1y'><ins id='7QN1y'></ins><ul id='7QN1y'></ul><sub id='7QN1y'></sub></form><legend id='7QN1y'></legend><bdo id='7QN1y'><pre id='7QN1y'><center id='7QN1y'></center></pre></bdo></b><th id='7QN1y'></th></span></q></dt></tr></i><div id='7QN1y'><tfoot id='7QN1y'></tfoot><dl id='7QN1y'><fieldset id='7QN1y'></fieldset></dl></div>

                        <legend id='7QN1y'><style id='7QN1y'><dir id='7QN1y'><q id='7QN1y'></q></dir></style></legend>

                        <small id='7QN1y'></small><noframes id='7QN1y'>