tag:blogger.com,1999:blog-2543858175797658864.post3070608123018059298..comments2023-06-03T09:48:30.964-04:00Comments on Trash Can of Code: Returning arrays in C++ (including multi-dimensional arrays)cottonvibeshttp://www.blogger.com/profile/15542648017139504620noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2543858175797658864.post-17660446867921349492016-09-12T07:41:39.558-04:002016-09-12T07:41:39.558-04:00In the line:
int (&arr)[n][m] = (int(&)[n]...In the line:<br />int (&arr)[n][m] = (int(&)[n][m])*ptr;<br />Where the results retrieved from the function are stored into a new array "arr", how can i replace the array "arr" (on the LHS), with a function that already exists in the scope, meaning that i would assign the array returned from the function to an existing function.M.Shttps://www.blogger.com/profile/10297436977873486892noreply@blogger.comtag:blogger.com,1999:blog-2543858175797658864.post-43038817861532250252014-01-31T16:18:30.297-05:002014-01-31T16:18:30.297-05:00What you should do is not allocate that struct on ...What you should do is not allocate that struct on the stack. So either declare the struct object outside of the function, or use dynamic allocation to allocate it on the heap. (i.e. use the 'new' operator, MyStruct* p = new MyStruct()).<br />You can also use the "static" keyword, "static MyStruct st;" although keep in mind this won't be thread safe if you do.cottonvibeshttps://www.blogger.com/profile/15542648017139504620noreply@blogger.comtag:blogger.com,1999:blog-2543858175797658864.post-52408047238595970142014-01-22T04:11:27.433-05:002014-01-22T04:11:27.433-05:00hi,
I am using struct operation in my code to save...hi,<br />I am using struct operation in my code to save output of my program which is a 2D array. So far I can do this ; if my array dimension is lower for example- if I have initialized 8 2D arrays with dimensions as [10][10] of type double . They are being used to save matrix result generated my program code in the main function. But now I want to change the dimensions to a larger value say [ 1000][1000] but is unable to do so as I am causing the stack to overflow can you please tell me how to overcome this problem.Anonymoushttps://www.blogger.com/profile/04112640905794292727noreply@blogger.com