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

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

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

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

        C++ - 未初始化向量的值<int>

        时间:2023-09-15
          <bdo id='xHiN7'></bdo><ul id='xHiN7'></ul>
        • <small id='xHiN7'></small><noframes id='xHiN7'>

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

              <tfoot id='xHiN7'></tfoot>
                  本文介绍了C++ - 未初始化向量的值<int>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我从 这个问题 global/static uninitialized int 的值将为 0. this 表示对于向量,将调用对象类型的默认构造函数.

                  I understand from the answer to this question that values of global/static uninitialized int will be 0. The answer to this one says that for vectors, the default constructor for the object type will be called.

                  我无法弄清楚 - 当我有 vector 时会发生什么v(10) 在本地函数中.int 的默认构造函数是什么?如果我有 vector 怎么办?v(10) 全局声明?

                  I am unable to figure out - what happens when I have vector<int> v(10) in a local function. What is the default constructor for int? What if I have vector<int> v(10) declared globally?

                  我看到的是 vector本地函数中的 v(10) 导致变量为 0 - 但我不确定这是因为我的编译器还是固定的预期行为.

                  What I am seeing is that vector<int> v(10) in a local function is resulting in variables being 0 - but I am not sure if that is just because of my compiler or is the fixed expected behaviour.

                  推荐答案

                  零初始化在标准中被指定为内置类型的默认零初始化/值初始化,主要是为了在模板使用中支持这种类型的情况.

                  The zero initialization is specified in the standard as default zero initialization/value initialization for builtin types, primarily to support just this type of case in template use.

                  >

                  请注意,此行为与诸如 int x; 之类的局部变量不同,后者会使值未初始化(如在继承行为的 C 语言中).

                  Note that this behavior is different from a local variable such as int x; which leaves the value uninitialized (as in the C language that behavior is inherited from).

                  这篇关于C++ - 未初始化向量的值<int>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:向量和常量 下一篇:向量的小字符串优化?

                  相关文章

                  最新文章

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

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

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

                      <tfoot id='pb8pb'></tfoot>