Re: ?? warning: ANSI C++ forbids implicit conversion from `void *' in initialization ???



It's because the C standard contains an error (I'm sure somebody out
there is going to disagree with me as to whether it's an error or
not!), and has defined NULL as an integer instead of as a pointer.
While it can be cast to a null pointer, if you have an overloaded
function that will accept either a null pointer or an int, it'll call
the int version.  A good description of the problem can be found at http://groups.google.com/groups?q=null+group:comp.lang.c%2B%2B&hl=en&selm=36ca3f75.517359233%40nntp.ix.netcom.com&rnum=5

You can almost always get away with using NULL, and using it does a
better job of conveying what your code is trying to do (IMHO).  But
when you do run into this subtlty, it will take weeks to find the
bug...  Using 0 has some remote hope of reminding you...
-- 
Joseph J. Pfeiffer, Jr., Ph.D.       Phone -- (505) 646-1605
Department of Computer Science       FAX   -- (505) 646-1002
New Mexico State University          http://www.cs.nmsu.edu/~pfeiffer
Southwestern NM Regional Science and Engr Fair:  http://www.nmsu.edu/~scifair



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]