[Solved] c++ pass-by-value, pass-by-reference or pass by value result [closed]


Function inc does not change the original values of array a. It accepts arguments by values that is it deals with copies of the arguments.

If you want that the function would change the arguments it should be defined like

void inc (int &x,int &y ){
    x++;
    y++;
}

In this case for a function call like this

i = 0;
inc (a[i],a[i]);

the output will be

3 
1

solved c++ pass-by-value, pass-by-reference or pass by value result [closed]