home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:13213 comp.os.ms-windows.programmer.misc:1648 comp.os.ms-windows.programmer.tools:840
- Newsgroups: comp.lang.c++,comp.os.ms-windows.programmer.misc,comp.os.ms-windows.programmer.tools,comp.windows.ms.programmer
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: I Borland C++/Win 3.1 Broken??? Help!
- Message-ID: <1992Sep2.164949.11421@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Sep1.213224.7550@actrix.gen.nz>
- Date: Wed, 2 Sep 1992 16:49:49 GMT
- Lines: 34
-
- David.Haigh@bbs.actrix.gen.nz writes:
-
- >The following member function compiles without error, using Turbo C++
- >for Windows 3.0.
-
- >virtual int yield( volatile BOOL & continueYield = TRUE);
-
- >BOOL : typedef for int
- >TRUE : #define 1
-
- >However, using Borland C++ for Windows 3.1, the following errors are generated:
-
- >* Reference initialised with 'int', needs lvalue of type int.
- >* Type mismatch in default value for parameter 'continueYield'.
-
- It looks like Borland fixed a compiler bug in the later release.
-
- You cannot initialize a non-const referernce with a constant.
- TRUE is a literal (constant) integer, and may be passed only to a
- a const reference. If a function has a non-const reference parameter,
- it is allowed to change the passed-in value. You can't change a
- literal constant, which is why it is illegal.
-
- Either pass in a variable initialized to TRUE, or declare the function
- parameter to be a const reference. If it does not change the value of
- its actual argument, it should be declared const anyway. If it does
- change its actual argument, you can't pass it a literal.
-
- This is legal, assuming you really want 'volatile' as well:
- virtual int yield( const volatile BOOL & continueYield = TRUE);
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-