调试断言失败:_BLOCK_TYPE_IS_VALID

kaj*_*acx 1 c++ memory-management dynamic-memory-allocation

在C++中使用以下代码:

class Foo {
    vector<Foo*> otherFoos;
};

int _tmain(int argc, _TCHAR* argv[])
{
  Foo* data = new Foo[5];
  delete data;
}
Run Code Online (Sandbox Code Playgroud)

我得到以下错误: 在此输入图像描述

我正在使用Visual Studio 2013.我不知道我的代码有什么问题.

tim*_*rau 5

你应该写delete [] data;.delete因为new,delete[]new[].