Ребята У меня возникла проблема с реализацией деструктора моего класса, который имеет map<int,list<Arestas*>>.
Используя эту карту в качестве примера: ![graph](https://i.stack.imgur.com/6EjA8.png)
Myкарта будет выглядеть так:
key list
[1] - [2,10] -> [3,100] -> [4,25]
[2] - [1,10] -> [3,50]
[3] - [2,50] -> [1,100] -> [4,40]
[4] - [1,25] -> [3,40]
Мой класс Arestas содержит:
class Arestas {
private:
Fronteira *vertice;
unsigned int custo;
}
Мой деструктор сейчас выглядит так:
for (auto it = myGrafo.begin(); it != myGrafo.end(); ++it) {
for (auto it1 = (*it).second.begin(); it1 != (*it).second.end(); ++it1) {
delete *it1;
}
(*it).second.clear();
}
Но дает мнеЭта ошибка, когда я иду по списку от ключа [2]:
_CRT_SECURITYCRITICAL_ATTRIBUTE
void __CRTDECL operator delete(void* const block) noexcept
{
#ifdef _DEBUG
_free_dbg(block, _UNKNOWN_BLOCK);
#else
free(block);
#endif
}
Заранее спасибо!
РЕДАКТИРОВАТЬ Я вставляю в свою карту Arestas*
как это:
Arestas *aux = new Arestas();
aux->setCusto(_custo);
aux->setVertice(encontrarFronteira(vertice_destino));
// Se o vertice nao existir
if (aux->getVertice()->getVertice() == NULL) {
cout << "ERROR" << endl;
exit(1);
}
myGrafo[vertice_origem].push_back(aux);
// Put the same path in the opposite vertice
Arestas *aux1 = new Arestas();
// set cost
aux1->setCusto(_custo);
// it looks for the vertice in the list<vertices*>
aux1->setVertice(encontrarFronteira(vertice_origem));
myGrafo[vertice_destino].push_back(aux1);