Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have class in which there is function.
my requirement is fucntion should return 2D array.But when i try this gives me array.
Posted
Comments
CPallini 29-Sep-11 8:24am    
Could you please elaborate? Could you please post the relevant code?
Usually the caller provides the required array while the called function fills it.
Albert Holguin 29-Sep-11 9:27am    
Are you planning on allocating the array dynamically (as in you don't know the dimensions of the array/matrix)? If so, it starts to get more difficult since its hard to conserve the dimensions while passing pointers (still doable, but harder).

You can return the start address for the array. For 2D it will be pointer to pointer.
Example a[][] is equivalent to **a.
 
Share this answer
 
Suppose int nArr[][] is 2d array then try this
return nArr;
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900