C++ setting reference variable in a class and afterwards changing
<p>Say I have a class Foo with a reference variable of type Bar and a constructor like so:  </p>

<p>Foo.h:  </p>

<pre><code>class Foo {
  public:
    Bar&amp; m_b;

    Foo(Bar&amp; b);
}
</code></pre>

<p>Foo.cpp</p>

<pre><code>Foo::Foo(Bar&amp; b) : m_b(b) {
}
</code></pre>

<p>And in a separate class I have:</p>

<pre><code>// global 
Bar b; 
Foo f(b);

int main() {   
  b.setData();       // actually set some values...
  f.m_b.showData();  // will it show the change?
  return 0; 
}
</code></pre>

<p>Will the reference variable in f also have that change of data after setData() is called?  I am trying this work-around because I have a class that has a reference variable (which must be set during initialization) but I need it to be globally accessible (declared before actually setting the data in Bar).</p>
