Hi All,

While running the below code i am getting

Error like :-

In member function ‘void Matrix::get_element(int, int, int)’:

cons_2d_array.cpp:13:9: error: invalid types ‘int[int]’ for array subscript

cons_2d_array.cpp: In member function ‘int& Matrix: put_element(int, int)’:

cons_2d_array.cpp:16:23: error: invalid types ‘int[int]’ for array subscript

cons_2d_array.cpp: In constructor ‘Matrix::Matrix(int, int)’:

cons_2d_array.cpp:23:18: error: cannot convert ‘int**’ to ‘int*’ in assignment

cons_2d_array.cpp:25:28: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]

Code:class Matrix { int *p; int d1,d2; public: Matrix() {d1=0;d2=0;} Matrix(int x,int y); void get_element(int i, int j, int value) {p[i][j]=value;} int & put_element(int i, int j) {return p[i][j];} }; Matrix :: Matrix(const int x, const int y) { d1=x; d2=y; p = new int *[d1]; for(int i=0; i<d1; i++) p[i]= new int[d2]; }