In either C or C++, should I check pointer parameters against NULL/nullptr?

后端 未结 20 2336
有刺的猬
有刺的猬 2020-11-27 03:54

This question was inspired by this answer.

I\'ve always been of the philosophy that the callee is never responsible when the caller does something stupid, like passi

20条回答
  •  不知归路
    2020-11-27 04:47

    If you don't want a NULL then don't make the parameter a pointer.
    By using a reference you guarantee that the object will not be NULL.

提交回复
热议问题