title: Do you use NULL or 0 (zero) for pointers in C++?
body: <p>In the early days of C++ when it was bolted on top of C, you could not use NULL as it was defined as <code>(void*)0</code>. You could not assign NULL to any pointer other than <code>void*</code>, which made it kind of useless. Back in those days, it was accepted that you used <code>0</code> (zero) for null pointers.</p>
  
  <p>To this day, I have continued to use zero as a null pointer but those around me insist on using <code>NULL</code>. I personally do not see any benefit to giving a name (<code>NULL</code>) to an existing value - and since I also like to test pointers as truth values:</p>
  
  <pre><code>if (p &amp;&amp; !q)
    do_something();
  </code></pre>
  
  <p>then using zero makes more sense (as in if you use <code>NULL</code>, you cannot logically use <code>p &amp;&amp; !q</code> - you need to explicitly compare against <code>NULL</code>, unless you assume <code>NULL</code> is zero, in which case why use <code>NULL</code>).</p>
  
  <p>Is there any objective reason to prefer zero over NULL (or vice versa), or is all just personal preference?</p>
  
  <p>Edit: I should add (and meant to originally say) that with RAII and exceptions, I rarely use zero/NULL pointers, but sometimes you do need them still.</p>