home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progc / fixed300.arj / V18.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  647 b   |  36 lines

  1. #if 0
  2. From: Victor Griswold
  3. Subject: Conditional assignment of structs
  4. Status: Fixed in 3.0
  5. #endif
  6.  
  7. /*
  8.     ZTC refuses to accept conditional assignment of class objects, whether or
  9. not an operator= is declared for the class.  This is legal C++.  ZTC 2.06
  10. accepted this, but incorrectly.  It performed bitwise copy of structs in
  11. conditional assignment whether or not an operator= was declared for the
  12. struct.
  13. */
  14.  
  15.  
  16. struct ref {
  17.     int r;
  18.  
  19.     ref& operator=(const ref &src);
  20. };
  21.  
  22.  
  23. ref& ref::operator=(const ref &src) {
  24.     r = src.r + 1;
  25.  
  26.     return *this;
  27. }
  28.  
  29. void main() {
  30.     ref r1, r2, r3;
  31.  
  32.     r1 = r2;
  33.  
  34.     r1 = (1 > 0)? r2 : r3;
  35. }
  36.