Процесс завершен с кодом выхода при нажатии на вектор вектора указателя C++C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Процесс завершен с кодом выхода при нажатии на вектор вектора указателя C++

Сообщение Anonymous »


I'm executing this function to push to a specific location of a vector a new pair of objects. But as soon the program tries to execute the push_back (emplace_back) function. The program gets stuck and I get it returns without any clear errors:

Process finished with exit code -1073741819 (0xC0000005) vector ug; vector foundPaths; void graph::addUndirectedRoute(const city& city1, const city& city2, double distance) { static int maxId = max(city1.id, city2.id); if (maxId >= ug.size()) { while(maxId > ug.size()) { ug.push_back(nullptr); } } if(ug[city1.id] == nullptr) ug[city1.id] = new vector(); if(ug[city2.id] == nullptr) ug[city2.id] = new vector(); ug[city1.id]->emplace_back(city2.id, distance); // execution gets stuck here ug[city2.id]->emplace_back(city1.id, distance); What could potentially go wrong


Источник: https://stackoverflow.com/questions/781 ... r-vector-c
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»