Debug assertion failed BLOCK_TYPE_IS_VALID(pHead->nblockuse) from Deconstructor

前端 未结 2 567
时光说笑
时光说笑 2021-01-27 05:06

I am quite lost right now. I made a vector class. Everything works how I would like it to work, until the end. When the destructor is called I get an error message: Debug ass

2条回答
  •  [愿得一人]
    2021-01-27 06:03

    _myArray = setterVect._myArray;
    

    Your copy assignment operator is broken. After that operator, both instances have the same value for _myArray. So as soon as one is destructed, the other one is left with a pointer to something that no longer exists.

    And the moral of the story -- use std::vector.

提交回复
热议问题