home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13712 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  1.4 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!apple!moon!gordie
  2. From: gordie@duts.ccc.amdahl.com (Gordie Freedman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Comma operator for stream I/O (was: Answer
  5. Message-ID: <72405@apple.Apple.COM>
  6. Date: 15 Sep 92 22:22:35 GMT
  7. References: <4958@holden.lulea.trab.se>
  8. Sender: daemon@Apple.COM
  9. Reply-To: gordie@duts.ccc.amdahl.com
  10. Organization: Happy hacker bait and tackle shop
  11. Lines: 38
  12.  
  13. In article 4958@holden.lulea.trab.se, jbn@lulea.trab.se (Johan Bengtsson) writes:
  14.  
  15. >Since I am also in search of an example where the comma operator would be
  16. >a good choice:
  17. >
  18. >Would the comma operator have been a good choice for stream I/O?
  19. >I.e. instead of the rather hard-to-read expression
  20. >
  21. >  cout << "The value is " << value << endl;
  22. >
  23. >you would write
  24. >
  25. >  cout, "The value is", value, endl;
  26. >
  27. >The precedence is just right (very low).
  28. >
  29. >The comma operator could be used for input as well:
  30. >
  31. >  int i; float f; char c;
  32. >  cin, i, f, c;
  33. >
  34.  
  35. I'd rather see this:
  36.  
  37. cin >> i, f, c;
  38. cout << "this is the value of i: ", i, endl ;
  39.  
  40. >--------------------------------------------------------------------------
  41. >| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  42. >| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
  43. >--------------------------------------------------------------------------
  44.  
  45.  
  46.  
  47. ---
  48. Gordie Freedman: gordie@kaleida.com Sigs are for kids
  49.  
  50.  
  51.