将一个2D数组从一个类传递到另一个类C ++

时间:2016-04-27 22:41:00

标签: c++

我确定这可能是一个重复的问题,但我很难将2D数组从一个类传递到另一个类中的函数 - 看起来它只期望一个参数而不是四个。我是C ++的新手,所以我可能会遗漏一些明显的东西。这基本上是代码的样子:

//global variables
  int NN;


 class x
{
...

void w(const int arr[][cow], int pig, int cow, int NN) //my problem is in here, the compiler will come up with errors like there is an expected ) before the first [] in my array and that cow isn't a variable in the scope even though from what i can tell i shouldn't have to declare it if i'm passing it in
{
    ... //nothing in the actual block of code has been setting off errors so i don't think its anything in here 

}

};

class y
{
...

void e() //this function by itself compiles
{
    int arr[NN][NN + 1];
    int pig = 0;
    int cow = 0;
    x* temp = NULL;

    ...
        //the function call 
        temp->w(arr, pig, cow, NN);
    ...


}
};

如果我需要发布更多代码,我可以,但我真的认为它只是在我如何通过它;提前感谢您的帮助

0 个答案:

没有答案