Your intent is not clear. What is getpointeM supposed to do? Return a pointer to the internal matrix (through the parameter), or return a copy of the matrix?
To return a pointer, you can do this
// Pointer-based version ... void getpointeM(double (**p)[3][3]) { *p = &M; } ... int main() { double (*A)[3][3]; moo.getpointM(&A); } // Reference-based version ... void getpointeM(double (*&p)[3][3]) { p = &M; } ... int main() { double (*A)[3][3]; moo.getpointM(A); }
For retpointM the declaration would look as follows
... double (*retpointM())[3][3] { return &M; } ... int main() { double (*A)[3][3]; A = moo.retpointM(); }
This is rather difficult to read though. You can make it look a lot clearer if you use a typedef-name for your array type
typedef double M3x3[3][3];
In that case the above examples will transform into
// Pointer-based version ... void getpointeM(M3x3 **p) { *p = &M; } ... int main() { M3x3 *A; moo.getpointM(&A); } // Reference-based version ... void getpointeM(M3x3 *&p) { p = &M; } ... int main() { double (*A)[3][3]; moo.getpointM(A); } // retpointM ... M3x3 *retpointM() { return &M; } ... int main() { M3x3 *A; A = moo.retpointM(); }