In your main() function:
double *A[3][3];
creates a 3x3 array of double* (or paired pointers). In other words, 9 x 32-bit contiguous memory words for storing 9 memory pointers.
There is no need to make a copy of this array in main() if the class is not destroyed, and you still want to access this information. Instead, you can simply return a pointer to the beginning of this member array.
If you want to return a pointer to the internal member of the class, you really only need one pointer value in main() :
double *A;
But if you pass this pointer to a function and you need a function to update its value, you will need a double pointer (which will allow the function to return the actual value of the pointer back to the caller:
double **A;
And inside getpointM() you can just point A to the inner member ( M ):
getpointeM(double** A) { // Updated types to make the assignment compatible // This code will make the return argument (A) point to the // memory location (&) of the start of the 2-dimensional array // (M[0][0]). *A = &(M[0][0]); }
LeopardSkinPillBoxHat
source share