Visual C++ find line causing “Debug Assertion failed”

前端 未结 3 1772
野趣味
野趣味 2021-01-02 10:55

I am trying to get a C++ program that works fine when compiled with gcc to work properly on Visual C++. My problem is that I am now getting the following error:



        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 11:41

    I think the problem is that you are erasing members of the vector you are iterating through. What happens if you erase the first element?

    i 1 2 3 Ei v1 v2 v3

    If we erase 1 when i = 1, our vector indices and values are below and now i = 2.

    i 1 2 Ei v2 v3

    Ultimately, I think you can iterate past the end of the vector causing you to have a pointer that points past the end of the vector. Complete guess work here, but there is probably an easier way to do what you're trying to do. I just can't figure out what you're trying to do.

    It looks like you're trying to invert the rows and columns of a two dimensional array while storing the diagonal polygons int he array into a new array. Anyway, yes, but a red circle at the beginning of the for loop and walk through your code line by line.

    I would create temp vectors and then modify those ones in the for loop and then replace the vector openPolygonList.

提交回复
热议问题