You are passing value
by value, meaning the valuered
function has a local copy of the argument. If you want to affect the outside variable number
the function should look like this:
void valuered(int& value)
{
value-=30;
}
Here value
is being passed by reference, meaning any changes done to it inside the function will propagate to the actual argument that has been passed in.
Also note that I have changed the return type from int
to void
, since you are not returning anything. Not returning anything from a function declared to return a value makes the program have undefined behavior.