讨论/题目交流/二维数组传到另一个二维数组/
二维数组传到另一个二维数组

#include<iostream>
#include<string>

using namespace std;

/*class people
{

}*/

class migong
{
public:

void setMap(int *_map, int a, int b);

void printfinfo()

{

 for(int i = 0; i < 10; i++)
	
 {
		
    for(int j = 0; j < 20; j++)
		
    {
			
      cout << mg_cmap[i][j];
		
    }
		
    cout << endl;
  	
 }

}

private:

string road;

string wall;

int mg_cmap[0][0];
};

void migong::setMap(int *_map, int a, int b)
{

mg_cmap[a][b] = *_map;

}

int main()
{

int map[10][20] = {

{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
	
{0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0},
	
{0,0,1,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0},
	
{0,0,1,1,1,1,0,1,0,1,0,1,1,1,1,0,1,0,1,0},
	
{0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0},
	
{0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0},
	
{0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,1,0},
	
{0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0},
	
{0,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0},
	
{0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0},
	
};

migong mg;

mg.setMap(&map[0][0],10,20);

mg.printfinfo();

return 0;
}

为什么我打印出来全是0没有1呀,怎么这样传参对不对?

你的mg_cmap没创建空间

1