Attribute vector emptying itself
<p>I have two classes, derived from a common class.
The common class has a pure virtual function called execute(), which is implemented in both derived classes.
In the inherited class I have an attribute which is a vector. In both execute() methods I overwrite this vector with a result. I access both classes from a vector of pointers to their objects.
The problem is when I try to access the result vector form outside the objects. In one case I can get the elements (which are simply pointers), in the other I cannot, the vector is empty.</p>

<p>Code:</p>

<pre><code>class E;
class A{
  protected:
    vector&lt;E*&gt; _result;
  public:
    virtual void execute()=0;
    vector&lt;E*&gt; get_result();
};
vector&lt;E*&gt; A::get_result()
{
   return _result;
}
class B : public A
{
  public:
    virtual void execute();
};
B::execute()
{
   //...
   _result = tempVec;
   return;
}
class C : public A
{
  public:
    virtual void execute();
};
C::execute()
{
   //different stuff to B
   _result = tempvec;
   return;
}
main()
{
  B* b = new B();
  C* c = new C();
  b-&gt;execute();
  c-&gt;execute();
  b-&gt;get_result();//returns full vector
  c-&gt;get_result(); //returns empty vector!!
}
</code></pre>

<p>I have no idea what is going on here... I have tried filling _result by hand from a temp vector in the offending class, doing the same with vector::assign(), nothing works. And the other object works perfectly. I must be missing something....
Any help would be greatly appreciated.</p>
