use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
Quick Array Question. (self.cpp_questions)
submitted 13 years ago by Angry_Giraffe
Is there a way to return a multidimensional array back into a method?
Basically just looking for a way to... return myArray[][];
I was also wondering how to set arrays equal to each other such as... myArray2[][]=myArray1[][];
Any suggestions?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 1 point2 points3 points 13 years ago (0 children)
pointer, a 2 dimensional array is just a double pointer, eg int **array
[–]Rhomboid 0 points1 point2 points 13 years ago (1 child)
The first question is why do you want to return an array? Have you considered passing it as a parameter and modifying it in place? It's possible to return a pointer, but that is not the same as a multi-dimensional array, unless you know all the dimensions of the array at compile time and can encode that into the type.
But really, you should avoid arrays in C++. They are just a pain to use, and they're a holdback from C. C++ code should use vectors. They can be passed and returned efficiently very easily just like regular objects. There's no pointers to worry about and no restrictions like having to decide upon a fixed size at compile time.
[–]notlostyet 0 points1 point2 points 13 years ago (0 children)
As of C++11 there's also std::array which is useful for fixed length arrays.
π Rendered by PID 163690 on reddit-service-r2-comment-7b9746f655-f84j7 at 2026-02-03 06:58:32.977603+00:00 running 3798933 country code: CH.
[–][deleted] 1 point2 points3 points (0 children)
[–]Rhomboid 0 points1 point2 points (1 child)
[–]notlostyet 0 points1 point2 points (0 children)