开发者

Dynamic array of template objects in C++

#include <vector>

using namespace std;

int main(开发者_C百科)
{
    vector<int> *list = new vector<int>[33];
    delete[] list;
    return 0;
}

Any reason why the delete SIGSEGVs?


It doesn't matter if the type is a template or not. The compiler will expand the code to a normal type. Deleting an array created with new[] you always use delete[].

The code you pasted is a little unusual but technically valid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜