Is it safe to delete a NULL pointer?

前端 未结 7 1494
忘掉有多难
忘掉有多难 2020-11-22 06:51

Is it safe to delete a NULL pointer?

And is it a good coding style?

7条回答
  •  攒了一身酷
    2020-11-22 07:07

    I have experienced that it is not safe (VS2010) to delete[] NULL (i.e. array syntax). I'm not sure whether this is according to the C++ standard.

    It is safe to delete NULL (scalar syntax).

提交回复
热议问题