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

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

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

        C2070 - 操作数大小非法

        时间:2023-10-06
        <i id='Q3i9P'><tr id='Q3i9P'><dt id='Q3i9P'><q id='Q3i9P'><span id='Q3i9P'><b id='Q3i9P'><form id='Q3i9P'><ins id='Q3i9P'></ins><ul id='Q3i9P'></ul><sub id='Q3i9P'></sub></form><legend id='Q3i9P'></legend><bdo id='Q3i9P'><pre id='Q3i9P'><center id='Q3i9P'></center></pre></bdo></b><th id='Q3i9P'></th></span></q></dt></tr></i><div id='Q3i9P'><tfoot id='Q3i9P'></tfoot><dl id='Q3i9P'><fieldset id='Q3i9P'></fieldset></dl></div>
      1. <tfoot id='Q3i9P'></tfoot>

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

                1. <legend id='Q3i9P'><style id='Q3i9P'><dir id='Q3i9P'><q id='Q3i9P'></q></dir></style></legend>
                    <tbody id='Q3i9P'></tbody>

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

                  本文介绍了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 - 操作数大小非法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

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

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

                    1. <small id='NDinu'></small><noframes id='NDinu'>

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