A
Angus
m_contacts is a std::list<myobject>.
This way:
for (std::list<myobject*>::iterator it = m_contacts.begin();
it != m_contacts.end(); ++it){
delete *it;
m_contacts.erase(it);
}
Or this way:
std::list<myobject*>::iterator it = m_contacts.begin ();
while (it != m_contacts.end ())
{
delete *it;
it = m_contacts.erase (it);
}
Are there any advantages of one over the other?
This way:
for (std::list<myobject*>::iterator it = m_contacts.begin();
it != m_contacts.end(); ++it){
delete *it;
m_contacts.erase(it);
}
Or this way:
std::list<myobject*>::iterator it = m_contacts.begin ();
while (it != m_contacts.end ())
{
delete *it;
it = m_contacts.erase (it);
}
Are there any advantages of one over the other?