问题描述:

This simple piece of code causes a core dump. I'm using gcc 4.8.2 in Linux.

template <class T>

class X

{

T c;

};

int main(int argc, char **argv)

{

X<string> *x = new X<string>[7];

delete x;

return 0;

}

I appreciate any help, I'm really confused with this. It doesn't cause a core dump when I use int instead of string.

网友答案:

You called new [] so you need to call delete []:

delete [] x;
相关阅读:
Top