-1

I am programming a game where I have a class called Wizard and another class called Judge.

In main, I Wizard wizard[7][7];. And now I am suppose to hand the 7*7 Wizard array to a static method in Judge

static void Initialize(short teamMax, short wizardMax, Wizard*** wizard) {/*stuff...*/};

Well, the stuff (which the compiler did not find any error in) goes like:

    for (int i = 1, n = 1; i <= teamMax; i++)
    {
        for (int j = 1; j <= wizardMax; j++)
        {
            Judge::Livings[n] = wizard[i][j]; 
            n++; 
        }
    }

Now this part worked out fine, but when I was calling this function in main

Wizard wizard[7][7]; 
Judge::Initialize(teamMax, wizardMax, &wizard); 

It says "incompatible to the parameter of type".

I did some research but I just can't figure out what went wrong... so please help and thanks alot.

skittles sour
  • 479
  • 1
  • 4
  • 7
  • 1
    Arrays are *NOT* pointers! I'd use a multidimensional `std::array` instead of a multidimensional built-in in any case, especially when passing it into a function. Also, typically, for loops are [0, N) instead of (0, N]. That makes a big difference with the array access. – chris Aug 05 '13 at 03:13

1 Answers1

0

You should specify your array arg in Initialize as

static void Initialize(short teamMax, short wizardMax, Wizard wizard[][7]) 

read the following link:

http://www.cplusplus.com/doc/tutorial/arrays/

Karadur
  • 1,226
  • 9
  • 16