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

后端 未结 20 2331
有刺的猬
有刺的猬 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:31

    I don't think it's the responsibility of the callee to deal with such things

    If it doesn't take this responsibility it might create bad results, like dereferencing NULL pointers. Problem is that it always implicitly takes this responsibility. That's why i prefer graceful handling.

提交回复
热议问题