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

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

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

      <tfoot id='HmumC'></tfoot>
      <i id='HmumC'><tr id='HmumC'><dt id='HmumC'><q id='HmumC'><span id='HmumC'><b id='HmumC'><form id='HmumC'><ins id='HmumC'></ins><ul id='HmumC'></ul><sub id='HmumC'></sub></form><legend id='HmumC'></legend><bdo id='HmumC'><pre id='HmumC'><center id='HmumC'></center></pre></bdo></b><th id='HmumC'></th></span></q></dt></tr></i><div id='HmumC'><tfoot id='HmumC'></tfoot><dl id='HmumC'><fieldset id='HmumC'></fieldset></dl></div>
      1. C2070 - 操作数大小非法

        时间:2023-07-02

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

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

            • <small id='YPAYd'></small><noframes id='YPAYd'>

                <tbody id='YPAYd'></tbody>

                1. 本文介绍了C2070 - 操作数大小非法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  以下代码对我来说很好:

                  The following code looks fine to me:

                      #include <stdio.h>
                  
                      template <typename T>
                      struct A
                      {
                          static float m_kA[];
                      };
                  
                      template <typename T>
                      float A<T>::m_kA[] = {1.0f, 2.0f, 3.0f};
                  
                      int main()
                      {
                          printf("%d
                  ", 
                              sizeof(A<unsigned int>::m_kA) /
                              sizeof(A<unsigned int>::m_kA[0]));
                          return 0;
                      }
                  

                  但是当我用 VC9 编译时出现以下错误

                  But when i compile with VC9 i get the following error

                  error C2070: 'float []': illegal sizeof operand
                  

                  我希望这段代码能够编译.我错过了什么吗?有谁知道解决这种奇怪行为的方法(请注意,没有模板的完全相同的东西可以正常编译并输出 3).

                  I would expect this code to compile. Am i missing something? Does anyone know a way to fix this strange behavior (note that the exact same thing without the template compiles fine and outputs 3).

                  请注意,删除模板不是一个选项,我制作这个示例是为了重现我在代码中遇到的问题,我需要包含数组的类型作为模板.

                  Note that removing the template is not an option, i made this example to reproduce a problem that i'm having in a code where i need the type containing the array to be a template.

                  谢谢

                  推荐答案

                  http://ideone.com/3ssVi

                  它用 G++ 编译得很好.

                  it compiles fine with G++.

                  据我所知,它可能与此错误有关:

                  As far as i can see it can be related to this bug:

                  http://connect.microsoft.com/VisualStudio/feedback/details/759407/can-not-get-size-of-static-array-defined-in-class-template

                  这篇关于C2070 - 操作数大小非法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:RVO 是否适用于对象成员? 下一篇:std::unordered_map 非常高的内存使用率

                  相关文章

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

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

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