On Wed, Jan 7, 2009 at 6:14 PM, Jos Timanta Tarigan
<[email protected]> wrote:
> Im trying to make a function that return a 2D array that size are dependent
> to the other parameter eg:
>
> Color[][] scan( width, height)
>
> so the method will return a Color[width][height] object. But i notice that
> this way is not working in C++. What is the best way to do this? Why cant i
> return a 2D array?
You can't return an array directly out of a function like that, but
you can return a pointer to an array. Make you sure you properly
allocate memory for the array, of course, and be careful of returning
a pointer to an array created locally inside the function.
There are better C++ ways of doing this, of course, like wrapping the
array with a class and returning the object of that class.
-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi