Is it safe to delete a NULL pointer?

前端 未结 7 1495
忘掉有多难
忘掉有多难 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:09

    Deleting a null pointer has no effect. It's not good coding style necessarily because it's not needed, but it's not bad either.

    If you are searching for good coding practices consider using smart pointers instead so then you don't need to delete at all.

提交回复
热议问题