I have the following member data
vector<State<T>*> activeChildren;
I want to clean-up these pointers in my destructor
StateContainer<T>::~StateContainer() {
vector<State<T>*>::iterator it =
activeChildren.begin();
while(it!=activeChildren.end()) {
State<T>* ptr = *it;
it = activeChildren.erase(it);
delete ptr;
}
}
I get the following error from g++ 4.3.2 on Ubuntu:
./fsm2/StateContainer.cpp: In destructor ‘virtual ervan::StateContainer<T>::~StateContainer()’:
../fsm2/StateContainer.cpp:24: error: expected `;' before ‘it’
../fsm2/StateContainer.cpp:25: error: ‘it’ was not declared in this scope
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(...)