J
josh
Hi, if I have a method like this:
public static int[][] pass()
{
int a[][] = {{1,2},{3,4}};
return a;
}
and than
int z[][] = pass();
when I call this method it returns the value of 'a' that is
a pointer (reference) to the matrix created. So in the caller
z has that value.
But I have a doubt, when the method return the variable 'a' is garbaged
and
thus also its value so how is possible that z has that value?
May be because the method returns to 'z' a copy of the 'a' value like
any variable value?
In the c/c++ when I return a matrix or a pointer in the function that
variable must be set
as static otherwise it loose its value...
Is that wrong?
Thanks
public static int[][] pass()
{
int a[][] = {{1,2},{3,4}};
return a;
}
and than
int z[][] = pass();
when I call this method it returns the value of 'a' that is
a pointer (reference) to the matrix created. So in the caller
z has that value.
But I have a doubt, when the method return the variable 'a' is garbaged
and
thus also its value so how is possible that z has that value?
May be because the method returns to 'z' a copy of the 'a' value like
any variable value?
In the c/c++ when I return a matrix or a pointer in the function that
variable must be set
as static otherwise it loose its value...
Is that wrong?
Thanks