c++ class member function returns different variable
<p>I am facing a very strange situation.</p>

<p>The following is the partial code.  </p>

<pre><code>class Base

{
  friend class Child; 
protected:
  string goodstring;
  string wrongstring;
public:
  string GetGoodString(void) { return goodstring; }
}

Child::member_f()
{
  cout&lt;&lt;bs-&gt;GetGoodString()&lt;&lt;endl;     //bs is a Base object
}
</code></pre>

<p>By running <code>member_f()</code>, I get <code>wrongstring</code>, instead of <code>goodstring</code>!
I cannot understand how this can be happned. </p>

<p>On gdb, printing <code>bs-&gt;goodstring</code> prints the correct contents. 
However,  <code>bs-&gt;GetGoodString()</code> returns wrongstring. </p>

<p>My program is so big and I am confused what kind of assumptions to set..</p>

<p>I would really appreciate if you could teach me....</p>

<p>Thank you very much in advance.  </p>
