title: Std::vector is initialized to garbage. Weird behavior. Any ideas on what's up?
body: <p>My class has this member.</p>
  
  <pre><code>  std::vector&lt;AvaWrapper&gt; m_controls;
  </code></pre>
  
  <p>In my constructor I call </p>
  
  <pre><code>  m_controls.clear()
  </code></pre>
  
  <p>Then I call a member function that does m_controls.clear() again but it blows up with an assert. The debugger shows that m_controls has a half million or more entries though none of them are valid cause the debugger shows "Error: expression cannot be evaluated" when I expand the tree. So, my intuition is that the class is not created correctly cause this code did work but I later derived a class from this class and I call new() to create the parent. In it's new role as a base class it's blowing up. The this pointer however shows all the other member variables have valid data so my hunch is wrong. The constructor is getting called too. Any ideas? Thanks.</p>
  
  <p>UPDATE2:</p>
  
  <pre><code>Train::Train() : SpriteWindowFrame(200)
  {
    s_mutexProtectingTheGlobalData = new wxMutex();
    m_window_rect = NULL;
    m_thread = NULL;
    m_ok = false;
    m_accumulate_timer = new wxTimer();
    m_accumulate_timer-&gt;SetOwner(this, ACCUMULATE_TIMER_ID);
  
    m_autohide_timer = new wxTimer();
    m_autohide_timer-&gt;SetOwner(this, AUTOHIDE_TIMER_ID);
  
    m_autohide = false;
    m_autohide_period = 5000;
    m_controls.clear();
  }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code>//This version works.
  SpaceInit::SpaceInit()
  {
    //Use INI config store. If you need something else, just
    //create the appropriate object.
    m_config_store = new IniConfigStore();
  
    //Start up config. 
    Init(); 
  
    m_t = new Trains();
    return;
  }
  
  SpaceInit::~SpaceInit()
  {
    wxDELETE(m_config_store);
    return;
  }
  </code></pre>
  
  <p>I can do this:
  m_t->SomeMemberFunctionThatManipulatesVector()</p>
  
  <p>and it works.</p>
  
  <p>This one does not</p>
  
  <pre><code>SpaceInit::SpaceInit():Trains()
  {
    //Use INI config store. If you need something else, just
    //create the appropriate object.
    m_config_store = new IniConfigStore();
  
    //Start up config. 
    Init(); 
    return;
  }
  </code></pre>
  
  <p>I can't do:
  SomeMemberFunctionThatManipulatesVector()</p>
  
  <p>blows up on vector.</p>
  
  <p>I've just noticed that the this pointer really is messed up inside the Train() default consturctor. I thought it wasn't but it is. The Trains constructor runs 
  but everything is trashed. </p>
  
  <p>My Trains constructor code is run of the mill. Just initialize things, new a couple things, etc. The SpaceInit is created with SpaceInit* t = new SpaceInit(); Train is a derived class so maybe that has something to do with it?</p>