Passing arrays by Reference + Return arrays in a function

Hi all!

Could anybody give an example of
-how to pass an array (either more-d or not) by reference
-how to make a function return a(n) (more-d) array ;)

Thanks in advance!
See the bottom of this page and post again if you have any questions.
http://cplusplus.com/doc/tutorial/arrays/
I do no know what "more-d or not" means. I show an example how to pass an array by reference

1
2
3
4
5
6
7
8
9
10
11
12
const size_t M = 10;
const size_t N = 20;

void f( int ( &a ) [M][N]  ) { /* some code */ }


int main()
{
   int a[M][N];

   f( a );
} 
Thanks! void f( int ( &a ) [M][N] ) { /* some code */ } That was exactly what I was looking for! :)

Zhuge: thanks for the link, but there isn't explained how to pass arrays by reference.

EDIT: more-d means multidimensional: 2d, 3d, -> more-d :)
Last edited on
Topic archived. No new replies allowed.