In my c++ program I have this variable:
std::list<std::pair<MyClass,MyClass> * > * myList=new std::list<std::pair<MyClass,MyClass> * >()
How can I correctly delete all information of this structure to avoid memory leaks? I think to do in this mode:
list< pair< MyClass,MyClass> *>::iterator it;
for(it=myList->begin();it!=myList->end();it++){
delete *it;
}
delete myList;
Is it a correct approach?
Aucun commentaire:
Enregistrer un commentaire