question on array as a pointer

Sep 3, 2011 at 9:15pm
if an array is effectively a pointer to the first element, then passing an array in a function must necessarily be by reference, and can never be done by value ? is this correct, thanks
Sep 3, 2011 at 9:25pm
arrays are passed into functions by pointer, and yes you're correct they cannot be passed by value

1
2
3
void func(int[] arr)
{
}


the syntax makes it look like you're passing in a whole array but that's just to make it look pretty, you're really passing the address of the first element
Last edited on Sep 3, 2011 at 9:27pm
Topic archived. No new replies allowed.