Pointers,Multidimensional arrays

Write your question here.

1
2
3
    double matA[3][3]={{3,2,4},{3,3,4},{6,5,9}};
    myTriplet x(matA,3);

(The class has this constructor method list)
myTriplet(double** arr,int n)

Can anyone see why this does not work? the
I get the error: no matching function for call to 'myTriplet::myTriplet(double[3][3],int)'
note: candidate: myTriplet::myTriplet(double**,int )
note: no known conversion for argument 1 for 'double[3][3]' to 'double**'

closed account (SECMoG1T)
well double** arr is a pointer to a pointer of type double while matA
can be implicitly converted to a pointer to an array of three doubles and with pointer arithmetics you can access the other two indices "matA+1, matA+2" which are also pointers to an array of three doubles.

passing a two dimensional array to a function in pointer notation would follow something similary to this:

 
myTriplet(double (*arr)[3],int n) 


Last edited on
Topic archived. No new replies allowed.