home *** CD-ROM | disk | FTP | other *** search
- Path: news.rmii.com!usenet
- From: disch@aartronics.com
- Newsgroups: comp.lang.c++
- Subject: Boolean evaluation operator
- Date: 8 Mar 1996 22:35:32 GMT
- Organization: Aartronics Corp.
- Distribution: All
- Message-ID: <4hqcnk$aoj@natasha.rmii.com>
- Reply-To: disch@aartronics.com
- NNTP-Posting-Host: krypton.aartronics.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- We have a Boolean class that contains the following operator:
-
- // Returns 1 if THIS Boolean Object is false, and 0 if THIS Boolean Object
- // is true.
- int
- Boolean::operator!(); // No referenced object; operates on THIS
-
- When used in the following code fragment, compilation fails with the message
- "Error testbed.cpp 47: Illegal structure operation in function main()":
-
- Boolean bTrue = T;
- Boolean bFalse = F;
- if (!bFalse)
- {
- cout << "bFalse" << endl;
- }
- if (bTrue)
- {
- cout << "bTrue" << endl;
- }
-
- Is there a way to define an evaluation operator so that "if (bTrue)" will
- compile and execute as expected?
-
- Any input would be greatly appreciated.
-
- Bob Dischner
- Aartronics Corp
-
-