home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11270 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.4 KB  |  47 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: boolean (was: Re: typedef vs enum)
  5. Message-ID: <1992Jul21.170922.26941@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <DOUGM.92Jul19222728@titan.cs.rice.edu> <DAVEG.92Jul20220553@synaptx.synaptics.com>
  10. Date: Tue, 21 Jul 1992 17:09:22 GMT
  11. Lines: 34
  12.  
  13.     While we're talking of a boolean type (which has two
  14. values equivalent to 0 and 1), how about a ZERO type?
  15.  
  16.     Type ZERO only has ONE value---0 of course.
  17.  
  18.     What use is it, you ask?
  19.  
  20.     Plenty. 0 is very important.
  21.  
  22.     How often have you wanted to allow assignment
  23. or initialisation of a class to 0 (but not any other value?)
  24.  
  25.     For example, if p is a pointer, you can write
  26.  
  27.     p=0; // null pointer
  28.  
  29. But if it is a *smart* pointer, you would have to declare
  30. assignment of say int->smart, and give a run-time error
  31. if the int was non-zero.
  32.  
  33. [There are NO variables of type zero, the type name is, of course 0]
  34.  
  35.     class smart {
  36.         operator=(0) { // set pointer to null state }
  37.     };
  38.  
  39. Anyone?
  40.     
  41.  
  42. -- 
  43. ;----------------------------------------------------------------------
  44.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  45.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  46. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  47.