Changing variables.

Would there, by chance, be a way to have a variable constantly and automatically change to equal another variable?

Say you have variables o and p.

1
2
int o
int p


I know that you can say:

1
2
3
p = 3;
o = 6;
p = o;


p, in the end would equal 6. But if you were to change "o" at a later point, "p" would remain equal to 6. Is there any way to make "p" constantly equal "o"?

I know that

1
2
int o;
int p=o;


only works until you change the value of "o" :(

Much thanks, if you can help me out :D
References?

1
2
3
4
5
6
int o;
int& p = o;
o = 42;
assert( p == 42 );
p = 37;
assert( o == 37 );
Ah, thank you :)
Topic archived. No new replies allowed.