The following program explains how properly addressed variable don't loose their correct values
#include<iostream>
using namespace std;
void func_widout_address(int a, int b){
a = 10;
b = 30;
}
void func_wid_address(int &x, int &y){
x = 100;
y = 200;
}
int main(){
int a = 20;
int b = 40;
func_widout_address(a,b);
cout<<"a: "<<a<<", b: "<<b<<endl;
func_wid_address(a,b);
cout<<"a: "<<a<<", b: "<<b<<endl;
return 0;
}
// ** Output **
// a: 20, b: 40
// a: 100, b: 200