What happens if delete[] p fails?

后端 未结 6 836
醉酒成梦
醉酒成梦 2021-02-07 03:52

Suppose I have a pointer to a dynamically allocated array of 10 elements:

T* p = new T[10];

Later, I want to release that array:



        
6条回答
  •  无人及你
    2021-02-07 04:24

    To answer your second question, if you used std::vector instead, there wouldn't be any need for a call to delete, you're not using pointers (the vector class is internally I believe, but this is not up to you to manage).

提交回复
热议问题