3 ms·
> Nullptr is needed in C++ because `0` is the only definition of `NULL` that works with the type system, due to the lack of implicit `void` conversions.* > C d
by haileys 3y ago
> Nullptr is needed in C++ because `0` is the only definition of `NULL` that works with the type system, due to the lack of implicit `void` conversions.*
> C doesn't have this problem.
Except for conversions between data pointers and function pointers ;)
Initialization seems to be a special case, but with `-pedantic` the following code will show a warning on the initialization of `fp2`:
void* return_null() {
return 0;
}
int main() {
void(*fp1)() = 0;
void(*fp2)() = return_null();
return 0;
}
- saagarjha 3y agoPOSIX requires this to be supported as well.