In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days.
Should I use NULL or 0?
C++中NULL的定义与使用
最新推荐文章于 2024-08-08 22:18:35 发布
本文探讨了C++中NULL的定义及其与0的区别。作者倾向于避免使用宏,并偏好直接使用0来代替NULL。此外,文章还讨论了在预标准代码中NULL可能被不适当地定义为其他值的问题。
2857

被折叠的 条评论
为什么被折叠?



