Posted by: Arun | May 26, 2008

C++ FAQ Series #1

Ques: Should I use NULL or 0 in my program?

Ans: In C++, the definition of NULL is 0, so there is only an aesthetic difference. Its better to avoid macros, so usually all use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That’s less common these days.


Leave a response

Your response:

Categories