Way to link 2 variables in a class in C++
<p>Say I wanted to have one variable in a class always be in some relation to another without changing the "linked" variable explicitly.</p>

<p>For example: int foo is always 10 less than int bar.</p>

<p>Making it so that if I changed bar, foo would be changed as well. Is there a way to do this? (Integer overflow isn't really possible so don't worry about it.)</p>

<p>Example: (Obviously doesn't work, but general code for an understanding)</p>

<pre><code>class A
{
    int x;
    int y = x - 10; // Whenever x is changed, y will become 10 less than x
};
</code></pre>
