Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Please explain the formal parameter int &;; Arr[ 10] and parameter int (&; The meaning of arr) [10]
Please explain the formal parameter int &;; Arr[ 10] and parameter int (&; The meaning of arr) [10]
Int & In arr[ 10], arr first subscripts and then dereferences to obtain plastic data.

int(& amp; Arr)[ 10] In ARR, firstly, dereference operation is performed, and then subscript operation is performed to obtain plastic data.

The first parameter is reference passing, and the array of arr[] changes, for example, in the user-defined function void function (int&; Arr[ 10]), you can directly change the array arr [] in the function body that calls the function without the need for the return value of the function;

The second parameter int (&; Arr)[ 10], which is the address of an array element (the address of an element of ten address types) and is passed along with the value.

Almost, but this value is the address!

int(& amp; Arr)[ 10] This is a reference to a variable that points to an array of size 10.

For example:

void fun 2(int(& amp; arr)[ 10]) {

}

Transfer:

int a[ 10];

fun 2(a);

When called, fun2 function function does not copy another array by value, but refers to array A itself.

This is basically the same as using a pointer. The only difference is that the value passed by the pointer itself cannot be modified in the function body, only the value pointed by the pointer can be modified and can be reflected outside the function body.

I hope it helps you! thank you