I have this assignment to do where I need to declare and use a dynamically allocated matrix. It's initialized as a 7X7 grid with known data (seen below)
I tried out at least a thousand different ways, but each time the compiler won't get it, it will alert me of a problem with casting int[][] to int**. I added a screenshot of the code, would love some help!
#include <cstdlib>
#include "Map.h"
typedef int size_type;
typedef int** grid_type;
grid_type ppGrid;
size_type size_h;
size_type size_w;
int mapInitializer[7][7]=
{
{ 0 , 1 , 1 , 1 , 1 , 1 , 1},
{ 1 , 2 , 2 , 0 , 1 , 0 , 1},
{ 0 , 0 , 1 , 1 , 1 , 2 , 1},
{ 1 , 0 , 0 , 0 , 0 , 0 , 1},
{ 1 , 1 , 1 , 2 , 1 , 0 , 1},
{ 1 , 0 , 0 , 0 , 0 , 2 , 1},
{ 1 , 0 , 1 , 1 , 1 , 1 , 1}
} ;
Map::Map(){
grid_type ppGrid;
realloc(ppGrid,7);
for(int i=0;i<7;i++){
realloc(ppGrid[i],7);
}
ppGrid=mapInitializer;
}