i'm trying to hand 2-dimensional-Array to a function as a C++-reference, so i can write to it and use the changed values in my main-function. But somehow it doesn't work yet...
Can anyone help? I'm having an exam tomorrow. :D
Thanks in advance for any try.
If you know the size of your array at compile time then you can do it like this.
1 2 3 4
void readMatrix( int matrix )
/* Do stuff */
When you call it, you'd simply use:
readMatrix( matrix );
You don't really explicitly pass arrays by reference. They decay to pointers when passed about anyway.
If you didn't know the runtime size of your array, you could do this by using a pointer to a pointer parameter and passing in a dynamically sized array. As with all cases like this, I'll include the obligatory 'you're better off with vectors or std::arrays line'. So there it is. :-)