NULL check before deleting an object with an overloaded delete

前端 未结 11 1812
野性不改
野性不改 2020-12-18 18:24

This came up as one of the code review comments.

Is it a good idea to check for NULL before calling delete for any object?

I do understand delete operator c

11条回答
  •  无人及你
    2020-12-18 18:31

    I would say that that's more a reason to ensure that if you overload operator delete, then you should always have it check for NULL, otherwise you're breaking the semantics.

提交回复
热议问题