home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18497 < prev    next >
Encoding:
Text File  |  1992-12-29  |  1.3 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: testing for null pointer
  5. Message-ID: <9236421.23910@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <1992Dec28.181916.7484@litwin.com>
  9. Date: Tue, 29 Dec 1992 10:40:08 GMT
  10. Lines: 29
  11.  
  12. mbb@litwin.com (Mark Beyleveld) writes:
  13.  
  14. >Assuming I declare
  15. >
  16. >int* aPointer = 0;
  17. >
  18. >is it valid to write
  19. >
  20. >if (aPointer) {...}
  21.  
  22. Yes.
  23.  
  24. >Also, are the rules for pointers to member functions the same?
  25.  
  26. Yes. [See the reference manual sections 6.4.1 ('if' statements),
  27. 4.6 (null pointers), and 4.8 (null pointers to members)].
  28. Actually 6.4.1 is perhaps a little vague. It says
  29.     "The expression [in an 'if' statement] is evaluated and if it is
  30.      nonzero ..."
  31. Presumably what it means for a pointer to member to be "nonzero" is for it to
  32. be different to the pointer which results when a constant expression that
  33. evaluates to zero is converted to a pointer to member (i.e. different from
  34. a null pointer to member).
  35.  
  36. -- 
  37. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  38. This .signature virus is a self-referential statement that is true - but 
  39. you will only be able to consistently believe it if you copy it to your own
  40. .signature file!
  41.