| winecoding (26) | |||
|
I am having two matrices, A, B. I would like to pass A and B into a function, which calculate C=A-B, and return it. How to write this function using pointer passing. I tried to define it as
Should the function be defined as int **p = multiM(int **x1, int **x2, dim)
| |||
|
|
|||
| matsom (280) | |
| Sorry, I don't see any function definition, but yeah, that's how you do it with 2D arrays, try to search this site for more examples e.g: http://www.cplusplus.com/forum/articles/7459/ (using 2D vectors and pointers) | |
|
Last edited on
|
|
| m4ster r0shi (1996) | |||
Some template magic could also be useful here...
Passing (const) references to the arrays allows the compiler to deduce the type, which saves you some typing -> matrix_sub<double, 2, 3>(...)
| |||
|
|
|||