vendredi 4 août 2017

Debug Assertion Failed (at the start of the program)

I have compiled my program, but when I try to run it, it gives med the following error:

Debug Assertion Failed

I then tried to debug, and I noticed that the error box shows up at the very start of the program from the main menu.

I have read about Debug Assertion Fail in stack overflow, but couldn't solve my problem. From the error box I get the information that the problem is at line 1991 in the algorithm file. The only place where I use the algorithm class is in a find_if function:

bool Train::tryToAssemble(TrainStation *tStation)
{
    for (size_t i = 0; i < partsToHave.size(); i++)
    {
        int type = partsToHave[i];
        auto vehicleInStation = tStation->getvehicleInStation();

        auto it = find_if(vehicleInStation.begin(), vehicleInStation.end(),
            [type](Vehicle *f1) {return f1->getType() == type; });

        if (it != vehicleInStation.end())
        {
            connectedParts.push_back(*it);
            vehicleInStation.erase(it);
        }
    }

    if (connectedParts.size() == partsToHave.size())
    {
        status = "ASSEMBLED";
        return true;
    }

    status = "INCOMPLETE";
    return false;
}

Does anyone know what I am possibly doing wrong?

Would appreciate your help.

Aucun commentaire:

Enregistrer un commentaire