Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are in <strong>C++</strong>, just do :</p> <pre><code>struct Coder { float **data; }; typedef Coder *AUTO; </code></pre> <p>Also you have to be sure that the <code>AUTO</code> declaration is done after the declaration of your <code>struct</code> or you can <em>forward-declare</em> your <code>struct</code>.</p> <hr> <p>Also, it is possible that <a href="http://www.cplusplus.com/reference/cstring/NULL/" rel="nofollow"><code>NULL</code></a> is undefined.</p> <p>You can replace it by <code>0</code> or just look at the link I just gave you.</p> <p>Here is a <a href="http://ideone.com/7ToQT4" rel="nofollow"><strong>live example</strong></a>.</p> <hr> <p><strong>EDIT :</strong> The code you gave us cannot work :</p> <pre><code>#include &lt;tchar.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;math.h&gt; #include &lt;conio.h&gt; #include &lt;iostream&gt; struct Coder { float **data; // 2-D matrix }; typedef Coder *AUTO; AUTO myFeatures = new Coder; myFeatures-&gt;data = NULL; // Forbidden int main (){ myFeatures-&gt;data = new float *[2]; myFeatures-&gt;data[0] = new float [2]; } </code></pre> <p>You can only have declaration in namespace scope, not expression like that.</p> <p>In <em>§7.3.1/1</em> of the standard :</p> <blockquote> <p>namespace-body:<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;declaration-seq<sub>opt</sub></p> </blockquote> <p>which says the namespace-body can <em>optionally</em> contain only <em>declaration</em>.</p> <p>This code will work :</p> <pre><code>// Your includes struct Coder { Coder() : data(NULL) {} // Constructor who initialize data to NULL // via the member-initialization-list float **data; // 2-D matrix }; typedef Coder *AUTO; AUTO myFeatures = new Coder; // Do you want to keep it in global ?? // It's not a really good design int main (){ // You should put your declaration here. // myFeatures-&gt;data = NULL; useless now myFeatures-&gt;data = new float *[2]; myFeatures-&gt;data[0] = new float [2]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload