home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13464 < prev    next >
Encoding:
Text File  |  1992-09-10  |  974 b   |  35 lines

  1. Path: sparky!uunet!news.univie.ac.at!blekul11!frmop11!dearn!esoc!kkeyte
  2. Organisation: European Space Operation Centre (E.S.O.C)
  3. Date: Thursday, 10 Sep 1992 10:40:02 CET
  4. From: Karl Keyte <KKEYTE@ESOC.BITNET>
  5. Message-ID: <92254.104002KKEYTE@ESOC.BITNET>
  6. Newsgroups: comp.lang.c++
  7. Subject: Answers on a postcard...
  8. Lines: 25
  9.  
  10.  
  11. What does your compiler do with this one using the comma operator?  I've
  12. had different results (and a very surprising order for calling operator
  13. members) from different compilers.  Let me know 1) what you THINK (by
  14. looking at it) it should produce and 2) what you actually get?
  15.  
  16. Karl
  17.  
  18.  
  19. #include <iostream.h>
  20.  
  21. class X {
  22.    private:    int           value;
  23.    public:     int           operator , (int i) { return i+10; };
  24.                int           operator + (int i) { return value+i; };
  25.                X &           operator = (int i) { value=i; return *this; };
  26. };
  27.  
  28.  
  29. void main()
  30. {
  31.    X         x;
  32.  
  33.    cout << "Value is " << (x=1, x+1) << endl;
  34. }
  35.