home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!world!rr
- From: rr@world.std.com (Robert I Ransbottom)
- Subject: Initialization of external vars
- Message-ID: <BtxJrw.CB5@world.std.com>
- Followup-To: comp.lang.c++
- Summary: ???
- Sender: rr@world.std.com
- Organization: The World Public Access UNIX, Brookline, MA
- Distribution: usa
- Date: Wed, 2 Sep 1992 02:47:54 GMT
- Lines: 42
-
- // Seems that this should run true. [ C++3.0 ref man 3.4, 3.5, 6.7]
- // What am I missing?
- //
- // code & sample run follows,
- // rr@world.std.com
-
- #include <stream.h>
-
- class boolean {
- public:
- int boo;
- public:
- boolean(int a):
- boo((cerr << "initializing boo: " << boo << "\n", !!a)) {
- cerr << "assigning boo: " << boo << "\n";
- boo = !!a;
- }
- operator int () const {
- cerr << "convert boolean to int\n";
- return boo;
- }
- };
-
- boolean TRUE = 1;
- main()
- {
- if (TRUE) {
- cout << "boolean TRUE -- True.\n";
- } else {
- cout << "boolean TRUE -- False.\n";
- }
- if (TRUE.boo) {
- cout << "boolean TRUE.boo-- True.\n";
- } else {
- cout << "boolean TRUE.boo-- False.\n";
- }
- }
- // $ boolean
- // convers. boolean to int
- // boolean TRUE -- False.
- // boolean TRUE.boo-- False.
-
-