I'm trying to understand what the ampersand mean when it comes to function arguments/parameters.
What does the (int &a, int b) in functiontwo mean? Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int functiontwo (int &a, int b)
{
int z = a + b;
b = a + z;
a += z + b;
cout << "a = " << a << "b = " << b << "c = " << c << "\n";
return a + b + z;
}
int main()
{
int a = 2, b = 3, c;
c = functiontwo(b, a);
cout << "a = " << a << "b = " << b << "c = " << c << endl;
b = functiontwo(a, c);
cout << "a = " << a << "b = " << b << "c = " << c << endl;
return 0;
}