[Development] 0 vs. NULL

René J.V. Bertin rjvbertin at gmail.com
Fri Oct 9 17:51:01 CEST 2015


On Friday October 09 2015 13:58:37 Pocheptsov Timur wrote:

> if NULL was (void *)0 - you'd have a compilation error in C++, since there is no such implicit conversion.
> 
> And yes, void * in C++ can be indeed considered generic, because you can do this:
> 
> int * p = ...
> void * pv = p;

Coming from C I have some trouble with that concept of generic pointer. Once you're used that it implies not only "can be assigned to any type of pointer" but also "can be assigned any type of pointer" it's not so easy to remember which of the 2 properties has been dropped. I don't see any evident reason why in the above example it should be possible to assign p to pv without an explicit cast, but not the other way round.

R.



More information about the Development mailing list