简体   繁体   中英

Debug assertion failed: _BLOCK_TYPE_IS_VALID

in C++ on following code:

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

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

I get this following error: 在此处输入图片说明

I'm using Visual Studio 2013. I have no idea what is wrong with my code whatsoever.

You should write delete [] data; . delete for new , delete[] for new[] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM