title: Calling object function through object pointers
body: <p>My program contains a class, here's its simplified form:</p>
  
  <p>Units.h:</p>
  
  <pre><code>#define fullwidth 200
  #define fullheight 200
  
  class Units
  {
  public:
  
  [...]
  
  void MovingUp(Units* Detector[fullwidth][fullheight], Units Self);
  [...]
  }
  </code></pre>
  
  <p>It defines a function that takes two arguments as input: an array of object pointers for "Units" objects, and a special chosen "Units" object.</p>
  
  <p>Here's the main part:</p>
  
  <pre><code>#include "Units.h"
  
  [...]
  
  int i,j;
  Units* DetectorField[fullwidth][fullheight];
  Units Examples[20];
  
  for (j=0;j&lt;fullheight;j++)
  {
      for (i=0;i&lt;fullwidth;i++)
      {
          DetectorField[i][j] = NULL;
      }
  }
  </code></pre>
  
  <p>It creates the array of "Units" object pointers that is necessary for the function in "Units" and sets all those values to NULL at the very beginning.</p>
  
  <p>After that, I try to call the function of the object through one randomly chosen pointer. Obviously, if the pointer is referenced to NULL, the call is impossible, but Visual C++ shows error even before I run the program.</p>
  
  <pre><code>DetectorField[12][12]-&gt;MovingUp(DetectorField,DetectorField[12][12]);
  </code></pre>
  
  <p>For this version, Visual C++ writes after compiling: cannot convert parameter 2 from 'Units *' to 'Units' - of course, since <code>DetectorField</code> itself is an array of <em>pointers</em>. Then I try to reference to the object it points, this way:</p>
  
  <pre><code>DetectorField[12][12]-&gt;MovingUp(DetectorField,&amp;DetectorField[12][12]);
  </code></pre>
  
  <p>MSVC writes after compiling: cannot convert parameter 2 from 'Units **' to 'Units' </p>
  
  <p>There isn't clear for me, why the second version reference to the pointer of an object pointer, not to an object. Also, how should I write the function call on the right way?</p>