home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!microsoft.com!jimad
- From: jimad@microsoft.com
- Newsgroups: comp.lang.c++
- Date: 18 Jul 92 00:41 MDT
- Subject: Re: boolean (was: Re: typedef vs enum)
- Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
- Message-ID: <1992Jul17.204136.17450@microsoft>
- References: <1992Jul11.195547.18323@cmcl2.nyu>
- Nf-ID: #R:1992Jul11.195547.18323@cmcl2.nyu:1382747533:1992Jul17.204136.17450@microsoft:864179071:001:825
- Nf-From: microsoft.com!jimad Jul 18 00:41:00 1992
- Lines: 52
-
-
- In article <1992Jul16.222530.4197@sunb10.cs.uiuc.edu> pjl@sparc9.cs.uiuc.edu (Paul Lucas) writes:
- > I use:
- >
- > enum { false, true }; // intentionally unnamed
- > typedef unsigned char Boolean;
- ....
- > (I don't think it's possible _to_ use it improperly).
-
- Excuuse Me?
-
- ======
-
-
-
- #include "iostream.h"
-
- enum { false, true };
-
- typedef unsigned char Boolean;
-
- Boolean BoolInvertFunc(Boolean b)
- {
- return !b;
- }
-
- void SomeFunc(int i) { cout << "SomeFunc(int) invoked\n";}
- void SomeFunc(Boolean b) { cout << "SomeFunc(Boolean) invoked\n";}
-
- main()
- {
- Boolean b = true;
- unsigned char c = 'c';
-
- cout << c << '\n';
- cout << b << '\n'; // UNDIAGNOSED ERROR
-
- cout << ( c == BoolInvertFunc(BoolInvertFunc(c)) ); // UNDIAGNOSED ERROR
- cout << '\n';
-
- SomeFunc(b == true); // WRONG FUNCTION INVOKED
-
- // etc etc etc
-
- return 0;
- }
-
-
-
-
-
-
-