What is the best way to pass 2D arrays to a function? (C++) For my program, I have a 2D array (size: N by N) of some structs. I need to go through each element in the array and check its status, and change it if necessary. Because of this, I know I cannot pass it by value or else I wouldn't be able to change the values in the 2D array. But when passing it by reference, it usually has a type error or something. I am mostly confused on the syntax of the input parameters and how I should call the function. I have always had trouble with this in the past, and still don't really understand the standard/best way to do it. Would it be a pointer to the first [0][0] element? Please help, thanks! If you need more information just ask
What is the best way to pass 2D arrays to a function? (C++)
For my program, I have a 2D array (size: N by N) of some structs. I need to go through each element in the array and check its status, and change it if necessary. Because of this, I know I cannot pass it by value or else I wouldn't be able to change the values in the 2D array. But when passing it by reference, it usually has a type error or something. I am mostly confused on the syntax of the input parameters and how I should call the function. I have always had trouble with this in the past, and still don't really understand the standard/best way to do it. Would it be a pointer to the first [0][0] element? Please help, thanks!
If you need more information just ask
Trending now
This is a popular solution!
Step by step
Solved in 3 steps