I want to pass a pointer, of type double **x, by reference. I have tried two different option by passing **x and **&x, and both give same result for the test code I shown below. I was wondering which option is the correct. I am trying to implement the concept for my project.
The results are the same because the expression x[i][j] accesses the same double whether x is the original pointer to pointer to double (pass-by-reference) or x is a copy of the original pointer to pointer to double (pass by value).
To experience a difference in behavior, try to assign a new value to x itself, from within the function (e.g. allocate a new array of pointers to arrays)
Also, don't forget to delete everything you new'd or use vectors to save yourself the headache (or a third-party matrix library, to make this even simpler)