3 ms·
The standard example is: void f(int x); void f(char *x); ... f(0); // calls void f(int) That may seem contrived, but you may not know of the
by Someone 15y ago
The standard example is:
void f(int x);
void f(char *x);
...
f(0); // calls void f(int)
That may seem contrived, but you may not know of the f(int) overload, especially in combination with templates.
NULL, if #define'd as (void *)0, prevents that error.
- pmjordan 15y agoNULL is actually #defined to 0 in C++ as void* is not implicitly convertible to any pointer type as it is in C. So unlike in C there has been no safety in using NULL. Until now.