TITLE: A perspective on NULL PROBLEM: harry@elfuerte.fipnet.fi (Harri Pesonen) I found two interesting things in the book C++ Tutorial by Microsoft. Page 65: "If new cannot allocate the memory requested, it returns 0. In C++, a null pointer has the value 0 instead of the value NULL." I have always used 0 as a null pointer even in C, and I never understood why NULL was even invented. RESPONSE: rmartin@rcmcon.com (Robert Martin), 2 May 95 Back in the early days of C it was assumed that the size of a pointer was the same as the size of an int. Thus, 0 was used as the "null" pointer. And stdio.h (or some other standard header) declared the macro NULL to be 0. Later, segmented architectures were invented by some "genius" and other strange address conventions were encountered such that integers and pointers were not the same size. Consider the following function in C: f(p) int *p; { if (p) *p = 0; // clear out the int. } Now consider what would happen if you called it like so: f(0); If an int and a pointer are not the same size, then this call will crash since in C 0 is an int. Thus, NULL was redefined to ((char*)0) and later ((void*)0) In C++ however, the compiler always know the type of the argument to a function (except in the ... case where the same problem still exists!) So 0 can be used to represent a null pointer. In fact, 0 is a special constant whose type must be derived from context. [...]