Reference to a Two-Dimesional Array
<p>I want to implement a function with OpenGL to render a cylinder in C++. The signature of my function is as follows:</p>

<pre><code>#define POINTS_NUM  15
#define DEMESION    3

void drawCylinder( int slices, int segments, GLfloat (&amp;vertices)[ POINTS_NUM ][ DEMESION ] );
</code></pre>

<p>I want to use a reference to a two-dimensional array to limit user input, but some strange behavior is happening. When I implement the function declared as above, an linker error occurs:</p>

<blockquote>
  <p>Error 1 error LNK2005: "float (* vase)[3]" (?vase@@3PAY02MA) already defined in shapes.obj vase.obj VaseAndAnimation</p>
</blockquote>

<p>Here <code>vase</code> is defined as:</p>

<pre><code>GLfloat vase[ POINTS_NUM ][ DEMESION ];
</code></pre>

<p>At first, I thought there was something wrong with the last dimension. So I omitted it in my second trial. This time declaration of my function is like this:</p>

<pre><code>void drawCylinder( int slices, int segments, GLfloat (&amp;vertices)[ POINTS_NUM ][] );
</code></pre>

<p>Now a compile-time error occurs when invoked as (<code>vase</code> definition isn't changed):</p>

<pre><code>drawCylinder( 10, 10, vase );
</code></pre>

<p>Compile error:</p>

<blockquote>
  <p>Error 1 error C2087: 'vertices' : missing subscript d:\visual studio 2008\projects\project1\computer graphics\vaseandanimation\shapes.h 25 VaseAndAnimation</p>
  
  <p>Error 2 error C2664: 'drawCylinder' : cannot convert parameter 3 from 'GLfloat [14][3]' to 'GLfloat (&amp;)[14][1]' d:\Visual Studio 2008\Projects\Project1\Computer Graphics\VaseAndAnimation\vase.cpp 64 VaseAndAnimation</p>
  
  <p>Error 3 error C2087: 'vertices' : missing subscript d:\visual studio 2008\projects\project1\computer graphics\vaseandanimation\shapes.h 25 VaseAndAnimation</p>
  
  <p>Error 4 error C2087: 'vertices' : missing subscript d:\Visual Studio 2008\Projects\Project1\Computer Graphics\VaseAndAnimation\shapes.cpp 12 VaseAndAnimation</p>
</blockquote>

<p>From this error, I can see that parameter <code>vertices</code> is really treated a reference to a two-dimensional array, but why is <code>vase</code> parsed as <code>float (* vase)[3]</code> in my first version?</p>

<p>My IDE is Visual Studio 2008. I haven't tried it with GCC; is that behavior compiler-dependent?</p>

<p>Hope someone can give me a hand to get rid of the trap.</p>
