int main()
{
int get_no_eqn, get_no_var;
//get the values for above variables by user
float **matrix = newfloat* [get_no_eqn]; //creating a multi-dimensional array
for(ptrdiff_t i = 0; i < get_no_eqn; i++)matrix[i] = newfloat[get_no_var];
interchange(matrix[][], 5) //i think it shouldn't be matrix[][]
return 0;
}
void interchange(float &matrix[][], int final) //probably the wrong step
{
//Get matrix by reference and not by value
}
It's not possible to pass a multidimensional array without specifying all but the last dimension.
Also you probably don't need to pass by reference since matrix is already a pointer to a multidimensional array.
When you pass matrix what you essentially pass is a float** pointer.
You can pass the dimensions as extra arguments though.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int main()
{
int get_no_eqn, get_no_var;
//get the values for above variables by user
float **matrix = newfloat* [get_no_eqn]; //creating a multi-dimensional array
for(ptrdiff_t i = 0; i < get_no_eqn; i++)matrix[i] = newfloat[get_no_var];
interchange(matrix, get_no_var, get_no_eqn, 5)
return 0;
}
void interchange(float **matrix, int dim1, int dim2, int final)
{
//matrix is not copied but passed directly (can also be modified)
}