> > [...]
> > > Is it not a good idea to always set pointers to NULL?
> > It depends. "Always" isn't a useful word in computer programming. Also,
> > to be preferred to NULL. Who knows what some dork has set NULL to in a
> > header file somewhere? Whereas the definition of 0 as the null pointer
> > guaranteed by the language.
> NULL is the proper way to assign a pointer a value that does not
> point to anything.
> 0 is an integer. Although compilers generously convert the integer
> to a NULL for us, it adds a confusion factor that is unnecessary. It is
> not always intuitively obvious from a code listing that 0 is meant to be
> NULL. Also using a 0 creates a "magic number," a raw value whose meaning
> is not obvious.
defined in the language as a special case (a null-pointer constant that
can be converted to a pointer to any type implicitly), then we won't
have this trouble here:
std::cout << "foo(char*)\n";
std::cout << "foo(int)\n";
foo(NULL); // prints "foo(int)"
Passing 0 would mean a call to foo(int) without a doubt in this case,Quote:}
and I think that such a change in the Standard won't break any
existing code. We can also allow implicit conversion if (int)0 into
a null-pointer value. I do sincerely hope that it will make many
programmers' lives easier.
Any word from the circles close to the C++ Standard Committee?
Please remove capital A's from my address when replying by mail