Not necessarily... There are two types of functions
Pass by value
and
Pass by reference
in your case you are doing pass by reference, meaning you are making direct changes to a value
if you didn't use the &, you are doing pass by value, in other words you are making a copy of the value
return type is dependent on the function.
For instance if you wanted to do the addition of the 3 values being sent, you return the sum back to the function.
1 2 3
|
int sum(x, y, z){
return x+y+z;
}
|
if you wanted to make changes to the values being sent, use what you did
if you wanted to copy the values to do something different like check if the numbers are valid you could do something like
1 2 3 4 5
|
bool test(x, y, z){
if ( x < 0 || y < 0 || z < 0)
return false;
else return true;
}
|
or in your case, you wanted to get the squared value of each value.. you could do
1 2 3 4 5 6
|
void duplicate (int a, int b, int c)
{
a*=a; // a^2
b*=b; //b^2
c*=c; // c^2
}
|
then all the values you send would be squared