home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: boolean (was: Re: typedef vs enum)
- Message-ID: <1992Jul21.170922.26941@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <DOUGM.92Jul19222728@titan.cs.rice.edu> <DAVEG.92Jul20220553@synaptx.synaptics.com>
- Date: Tue, 21 Jul 1992 17:09:22 GMT
- Lines: 34
-
- While we're talking of a boolean type (which has two
- values equivalent to 0 and 1), how about a ZERO type?
-
- Type ZERO only has ONE value---0 of course.
-
- What use is it, you ask?
-
- Plenty. 0 is very important.
-
- How often have you wanted to allow assignment
- or initialisation of a class to 0 (but not any other value?)
-
- For example, if p is a pointer, you can write
-
- p=0; // null pointer
-
- But if it is a *smart* pointer, you would have to declare
- assignment of say int->smart, and give a run-time error
- if the int was non-zero.
-
- [There are NO variables of type zero, the type name is, of course 0]
-
- class smart {
- operator=(0) { // set pointer to null state }
- };
-
- Anyone?
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-