<small id='8vxhZ'></small><noframes id='8vxhZ'>

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

      1. <tfoot id='8vxhZ'></tfoot>

      2. <legend id='8vxhZ'><style id='8vxhZ'><dir id='8vxhZ'><q id='8vxhZ'></q></dir></style></legend>

        错误:用“{...}"初始化;预期聚合对象 - C++

        error: initialization with quot;{...}quot; expected for aggregate object - c++(错误:用“{...}初始化;预期聚合对象 - C++)
        • <i id='D200u'><tr id='D200u'><dt id='D200u'><q id='D200u'><span id='D200u'><b id='D200u'><form id='D200u'><ins id='D200u'></ins><ul id='D200u'></ul><sub id='D200u'></sub></form><legend id='D200u'></legend><bdo id='D200u'><pre id='D200u'><center id='D200u'></center></pre></bdo></b><th id='D200u'></th></span></q></dt></tr></i><div id='D200u'><tfoot id='D200u'></tfoot><dl id='D200u'><fieldset id='D200u'></fieldset></dl></div>

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

          <legend id='D200u'><style id='D200u'><dir id='D200u'><q id='D200u'></q></dir></style></legend>
            <tbody id='D200u'></tbody>
          <tfoot id='D200u'></tfoot>

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

                  本文介绍了错误:用“{...}"初始化;预期聚合对象 - C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  struct test
                  {
                      unsigned int test1;
                      unsigned char test2[4096];
                      unsigned int test3;
                  } foo
                  
                  struct foobar
                  {
                  unsigned char data[4096];
                  }
                  

                  如果我想访问结构体,我会说 foo.test1、foo.test2[4096] 等等.但是,当我希望以下列方式返回 foo.test2 中存在的数据时

                  if i want to access the struct, i say foo.test1, foo.test2[4096], etc.. however, when I wish to return the data present in foo.test2 in the following manner

                  pac.datafoo = foo.test2[4096];
                  
                  unsigned char data[4096] =  pac.datafoo;
                  

                  这是我得到的错误:

                  error: initialization with "{...}" expected for aggregate object
                  

                  我做错了什么?

                  推荐答案

                  需要学习数组的初始化方法.它不是简单地分配为单个变量.

                  You need to learn the array initialization method. It's NOT simply assigned as the single variable.

                  一些例子:

                  int arrayone[3] = {0}; // assign all items with 0
                  
                  int arraytwo[3] = {1, 2, 3 }; // assign each item with 1, 2 and 3
                  
                  int arraythree[3]; // assign arraythree with arraytwo
                  for (int i = 0; i < 3; ++i) {
                      arraythree[i] = arraytwo[i];
                  }
                  

                  这篇关于错误:用“{...}"初始化;预期聚合对象 - C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)

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

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