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

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

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

          <bdo id='F5i26'></bdo><ul id='F5i26'></ul>
      1. <tfoot id='F5i26'></tfoot>

        如何将简单指针转换为固定大小的多维数组?

        时间:2023-09-18

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

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

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

              • <bdo id='eC007'></bdo><ul id='eC007'></ul>
                1. 本文介绍了如何将简单指针转换为固定大小的多维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个函数,它接受一个指向浮点数组的指针.根据其他条件,我知道指针实际上指向一个 2x2 OR 3x3 矩阵.(实际上内存最初是这样分配的,例如 float M[2][2] )重要的是我想在函数体中做出这个决定,而不是作为函数参数.

                  I have a function that takes a pointer to a floating point array. Based on other conditions, I know that pointer is actually pointing to a 2x2 OR 3x3 matrix. (in fact the memory was initially allocated as such, e.g. float M[2][2] ) The important thing is I want to make this determination in the function body, not as the function argument.

                  void calcMatrix( int face, float * matrixReturnAsArray )
                  {
                      // Here, I would much rather work in natural matrix notation
                      if( is2x2 )
                      {
                          // ### cast matrixReturnAsArray to somethingAsMatrix[2][2]
                          somethingAsMatrix[0][1] = 2.002;
                          // etc..
                      }
                      else if(is3x3)
                      { //etc...
                      }
                  
                  }
                  

                  我知道我可以使用模板和其他技术来更好地解决这个问题.我的问题实际上是关于如何在 ### 评论中进行这样的演员表.使用 C++.

                  I am aware that I could use templates and other techniques to better address this problem. My question is really about how to make such a cast at the ### comment. Working in C++.

                  推荐答案

                  float (*somethingAsMatrix)[2] = (float (*)[2]) matrixReturnAsArray;
                  

                  这篇关于如何将简单指针转换为固定大小的多维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:C++ 重载运算符 [ ][ ] 下一篇:读取 Matrix txt 文件并存储为数组

                  相关文章

                  最新文章

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

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

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

                    <tfoot id='vmrdH'></tfoot>