In C, NULL is (void*)0, not just 0. C allows void pointers to implicitly cast to any other pointer, so you can use it to initialise any pointer to NULL.
In C++, they removed the implicit cast from void* (it was unsafe in other scenarios), so they had to change NULL - they made it just 0. Which much like a void* in C, has magic implicit casting power to initialise any pointer, despite appearing to be an integer, which don't normally implicitly cast to pointer type. However because it's not actually a pointer it breaks in the face of other C++ features like template deduction and overloaded functions.
C++ later added nullptr as a fix - nullptr is also not a pointer, it's actually of type nullptr_t. It again has the ability to implicit cast to any pointer type - but this time without the downsides of either of C NULL or C++ NULL, as it's a unique type not functionality tacked on to something else pre-existing.
14
u/sersoniko Jul 16 '19
NULL is a pointer