title: C++ iterator problems
body: <p>I have the following member data</p>
  
  <pre><code>vector&lt;State&lt;T&gt;*&gt; activeChildren;
  </code></pre>
  
  <p>I want to clean-up these pointers in my destructor</p>
  
  <pre><code>StateContainer&lt;T&gt;::~StateContainer() {
      vector&lt;State&lt;T&gt;*&gt;::iterator it =
          activeChildren.begin();
      while(it!=activeChildren.end()) {
          State&lt;T&gt;* ptr = *it;
          it = activeChildren.erase(it);
          delete ptr;
      }
  }
  </code></pre>
  
  <p>I get the following error from g++ 4.3.2 on Ubuntu:</p>
  
  <pre><code>./fsm2/StateContainer.cpp: In destructor ‘virtual ervan::StateContainer&lt;T&gt;::~StateContainer()’:
  ../fsm2/StateContainer.cpp:24: error: expected `;' before ‘it’
  ../fsm2/StateContainer.cpp:25: error: ‘it’ was not declared in this scope
  </code></pre>
  
  <p>Can anyone tell me what I've done wrong? I get this error in two more places where I use iterator loops, but not when I use for_each(...)</p>