Then when I print the address of B via fprintf(stderr,"B: %p\n",B), inside the function, I do not get the same address as outside the function. Where I instead get the address of tmp.
So it seems there is an issue with B inside the function, being a copy of B outside the function or in the main.
So why is this? And what can I do about it, so it is the actual B that is changed?
If you just want to manipulate values of pointer - matrix entries just pass pointer, but if you want to manipulate pointer itself, pass reference - like when swapping.
And also how would I declare B, so that it is a reference?
Because if I pass B to the function with double** & B, I get an error.
So is this good C++ programming practice or something that should be avoided?
Hard to say. It seemed like this was just an example for learning purposes. Learning how things work is good.
And if the other pointer you swap B with is static, the other pointer should keep its newly assigned address right?
I'm not quite clear on the question here. Perhaps you could show some actual code to clarify what you mean. (you might also test it yourself to see if it behaves as expected).
Roughly speaking yes. tmp will retain its value from one function call to the next.
However, these code samples don't compile, so the whole discussion feels very abstract. Trying to understand the C++ language while looking at invalid code doesn't seem a very sound plan to me. I suggest actually trying to compile and run some examples, and examine the contents of different variables (using a debugger is a good idea) during execution of the code.