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 Postreset(int (&Board)[2][3])
I have never in over 20 years seen anyone code a function prototype like that. Arrays are ALWAYS passed by reference, it is not possible to pass an array by value. So this is all that is needed
void reset(int Board[2][3]);
Jump to PostSo I'm still having a ton of issues with my functions that pass by reference. The compiler is giving me numerous errors with both the call and the function itself.
Here is the simplest function that passes by reference:
Does anyone have some ideas what's wrong?Yes --
1) pBoard …
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.