I have seen below macro in many topmost header files:
#define NULL 0 // C++03
In all over the code, NULL and 0 are used interchangeably. If I change it to.
#define NULL nullptr // C++11
Will it cause any bad side effect ? I can think of the only (good) side effect as following usage will become ill-formed;
int i = NULL;
You shouldn't have seen that, the standard library defines it in
<cstddef>(and<stddef.h>). And, IIRC, according to the standard, redefining names defined by standard header files results in undefined behaviour. So from a purely standardese viewpoint, you shouldn't do that.I've seen people do the following, for whatever reason their broken mind thought of:
(As in [incorrectly]: "set the virtual table pointer to
NULL")This is only valid if
NULLis defined as0, because= 0is the valid token for pure-virtual functions (§9.2 [class.mem]).That said, if
NULLwas correctly used as a null pointer constant, then nothing should break.However, beware that, even if seemingly used correctly, this will change:
However, if that was ever the case, it was almost certainly broken anyways.