My program contains a class, here's its simplified form:
Units.h:
#define fullwidth 200
#define fullheight 200
class Units
{
public:
[...]
void MovingUp(Units* Detector[fullwidth][fullheight], Units Self);
[...]
}
It defines a function that takes two arguments as input: an array of object pointers for "Units" objects, and a special chosen "Units" object.
Here's the main part:
#include "Units.h"
[...]
int i,j;
Units* DetectorField[fullwidth][fullheight];
Units Examples[20];
for (j=0;j<fullheight;j++)
{
for (i=0;i<fullwidth;i++)
{
DetectorField[i][j] = NULL;
}
}
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.
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.
DetectorField[12][12]->MovingUp(DetectorField,DetectorField[12][12]);
For this version, Visual C++ writes after compiling: cannot convert parameter 2 from 'Units *' to 'Units' - of course, since DetectorField itself is an array of pointers. Then I try to reference to the object it points, this way:
DetectorField[12][12]->MovingUp(DetectorField,&DetectorField[12][12]);
MSVC writes after compiling: cannot convert parameter 2 from 'Units **' to 'Units'
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?