Passing array to another classes failed?
Mar 17, 2017 at 4:57pm UTC
In the class called "Mouse", I have the following function, where it takes 2 array and 2 variable as parameter.
1 2 3 4 5 6 7 8 9 10
void Mouse::MoveUp(char c[][20],int d[][20],int e, int f)
{
if (c[e-1][f]=='-' )
{
c[e-1][f]=='O' ;
d[e-1][f]=d[e][f]+1;
c[e][f]=='-' ;
d[e][f]=0;
}
}
In the Brain class, I have the following function to call
1 2 3 4
for (int i=0;i<20;i++)
{
for (int j=0;j<20;j++)
Mouse::MoveUp(board,mmm,i,j);
But the array is not passed and nothing happened.
Mar 17, 2017 at 5:29pm UTC
Since your using such descriptive variable names (not) you may want to post more content. For example how are board and mmm defined and initialized? What do you expect to change and why?
Mar 17, 2017 at 10:57pm UTC
Hi,
1 2 3 4 5 6
for (int a=0; a<20; a++)
{
for (int b=0; b<20; b++)
board[a][b]='-' ;
}
mmm[20][20]= {0};
basically this program will execute and find if there's any cell with char "O" and move to it's adjacent cell if the adjacent cell is empty.
Topic archived. No new replies allowed.