Member value changes between successive calls of the same function
<p>I have a <code>CognitiveEntity</code> class, defined this way:</p>

<pre><code>class CognitiveEntity : public Object
{
public:
  CognitiveEntity (FuzzyCognitiveMap fcm, SystemState s);
  ~CognitiveEntity ();

  template &lt;typename T&gt; void RegisterChange (std::string context, T value);

  bool operator!= (const CognitiveEntity&amp; rhs) const;

private:
  FuzzyCognitiveMap m_fuzzyCognitiveMap;
  SystemState       m_systemState;

  std::vector &lt;SystemState&gt; RunFuzzyCognitiveMap ();
};
</code></pre>

<p>As shown, a <code>CognitiveEntity</code> has a <code>SystemState</code> object, which in turn has a vector of <code>Concept</code> objects (only the most relevant lines are shown):</p>

<pre><code>class SystemState
{
public:
  SystemState ();
  ~SystemState ();

  void       AddConcept (Concept c) { m_L.push_back(c); }
  std::vector &lt;Concept&gt; m_L;
};
</code></pre>

<p>Inside the <code>CognitiveEntity::RegisterChange</code>, I mark a Concept as a potential cause (by calling <code>Concept::IsPotentialCause (bool)</code> which merely sets a private member with the value passed):</p>

<pre><code>template &lt;typename T&gt;
void
CognitiveEntity::RegisterChange (std::string context, T value)
{
  std::string name = context.substr(context.find_last_of ("/") +1);
  int pos = m_systemState.FindConcept(name);
  if (pos &gt; -1)
  {
    int intValue = value ? 1 : 0;
    m_systemState.m_L[pos].SetConceptValue (intValue, false);

    if (m_systemState.m_L[pos].CheckVariation ())
    {
      m_systemState.m_L[pos].IsPotentialCause (true); // Mark this concept as a potential cause

      for (int cause = 0; cause &lt; m_systemState.GetSize (); cause++)
      {
        if ( (cause != pos) &amp;&amp; (m_systemState.m_L[cause].MayBeCause ()))
        {
          m_fuzzyCognitiveMap.UpdateFuzzyCognitiveMapEntry (cause, pos, m_systemState);
          m_systemState.m_L[cause].IsPotentialCause (false);
        }
      }
    }
  }

}
</code></pre>

<p>What happens is that as soon as <code>RegisterChange</code> is called another time, the <code>Concept</code> that was marked as potential cause, is marked no more.
I tried running gdb and I am sure that that member is not set elsewhere.</p>

<p>I'm not sure if this little information is enough for you to give me some hints about such a behavior (I didn't want to flood the post with the code of both <code>SystemState</code> and <code>Concept</code> classes).</p>

<p>Regards,
Jir</p>
