- Pass by value is considered safer as you cannot accidentally
modify the parameter variable passed in the function and you may
not run into issues related to this.
- When passing an array to a function, the whole array is not
passed to the function.
- Instead, a pointer to the first element of the array is passed
to the function.
- Native arrays are not objects, they are just continuous memory
locations of the defined data type. The name of the array is a
pointer to the first element of the array. Example: int arr[10], is
nothing but 10 continuous int memory allocations and arr is the
address of the first element of the array. Adding 1 to arr will
give a pointer to the next memory location.
- Since it's just a pointer that is being passed to a function,
the only way of knowing where the upper bound of the array lies is
to manually pass in the size of the array.
- Keep in mind that even though the array has just 10 elements,
even arr+15 will work and accessing the location may give a garbage
value.
If you have any more queries, please post them down in the
comment section.