When you pass a variable to a function, C++ copies its value. The function gets a copy, not the original. Changes inside don't affect outside. This is pass by value, the default behavior.
Example: void increment(int x) { x++; }. Call increment(n) and the function adds 1 to the copy, then throws it away. Original n stays the same. This protects your data. Functions can't break variables they don't own.
If you want to modify the original, you need references.