So I have a multi-dimensional array, and I want to pass a reference of it to another function so that the array is defined in the scope of the function, because the array is not a global variable.
If I can remember correctly, the syntax looks a little like this:
reset(int &Board[][])
I'm not sure what to put inside the indice boxes either... Does anyone have any suggestions. I'm going to look on google a bit as well right now.
zoner7
22
Junior Poster
Recommended Answers
Jump to Posttry this code
void reset(int *board)
and in calling reset(arrayname)
in passing by raference we pass the address to the function as we do it in pointers i hope it will work.
you can not pass the reference of array because it gives error if you want to pass it's …
Jump to Post> I'm not sure what to put inside the indice boxes
Ed would recommend the size of the array as it's required for an array reference. ;)reset(int (&Board)[2][3])
The parentheses are also required to bind the reference operator to the array instead of to the type …
Jump to Posthai,
i am new one.
i am learning the c++ now.
it is such a interesting language.
the passing by reference is used to pass the arguments by addresses.
thanks..........
<snip>
All 9 Replies
architact
25
Junior Poster
Radical Edward
301
Posting Pro
jim2008
0
Newbie Poster
zoner7
22
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
zoner7
22
Junior Poster
Radical Edward
301
Posting Pro
Ancient Dragon
commented:
You are right! :)
+30
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.