home *** CD-ROM | disk | FTP | other *** search
- #if 0
- From: Victor Griswold
- Subject: Conditional assignment of structs
- Status: Fixed in 3.0
- #endif
-
- /*
- ZTC refuses to accept conditional assignment of class objects, whether or
- not an operator= is declared for the class. This is legal C++. ZTC 2.06
- accepted this, but incorrectly. It performed bitwise copy of structs in
- conditional assignment whether or not an operator= was declared for the
- struct.
- */
-
-
- struct ref {
- int r;
-
- ref& operator=(const ref &src);
- };
-
-
- ref& ref::operator=(const ref &src) {
- r = src.r + 1;
-
- return *this;
- }
-
- void main() {
- ref r1, r2, r3;
-
- r1 = r2;
-
- r1 = (1 > 0)? r2 : r3;
- }
-