[Dev-C++] Problem deleting iterator contents while iterating...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Edric T. <pp...@ho...> - 2003-09-30 07:04:37
|
Hi guys,
I've ran into a small problem here...
What I'm trying to do is to iterate through an STL data structure. On a =
successful match in criteria, I wish to delete the iterator and its =
contents away from the memory. However, when I attempted to call delete =
on the node that I want to remove, the compilation throws an error. =
Anyone knows what's going on? Here's the code for your reference:
for (ResultTable::iterator xIter=3DresultTable.begin(); =
xIter!=3DresultTable.end(); ) {
if (!matchFound) {
// Match was unsuccessfull
// TODO:
// Free memory allocated to this node
delete(*xIter); // Compilation fails at this point
resultTable.erase(xIter++);
}
else {
// Match was successful begin copying the additional =
columns=20
// over from y
++xIter;
}
}
Thanks and regards,
Ed |