home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16145 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.7 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!fmrco!pandrews!pandrews
  3. From: pandrews@lovat.fmrco.com (Paul Andrews)
  4. Subject: Re: operator [][]
  5. Message-ID: <1992Nov12.094813.28366@fmrco.uucp>
  6. Sender: news@fmrco.uucp
  7. Reply-To: pandrews@lovat.fmrco.com
  8. Organization: Fidelity Investments Ltd.
  9. References: <1992Nov11.182016.13511@ucc.su.OZ.AU>
  10. Date: Thu, 12 Nov 1992 09:48:13 GMT
  11. Lines: 48
  12.  
  13. In article 13511@ucc.su.OZ.AU, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  14. > In article <1992Nov9.114516.29846@alf.uib.no> s026@brems.ii.uib.no (Paal K Holmberg) writes:
  15. > >In article <1992Nov9.095352.19114@fmrco.uucp>, pandrews@lovat.fmrco.com (Paul Andrews) writes:
  16. > >|> 
  17. > >since it os a trouble to get around mutiple []'s , you can always cheat and use a 
  18. > >normal function element(int x,int y...) to get a certain element in the matrix or whatever.
  19. > >I agree it is not as elgant as the [] approach, but it is easy.
  20. > >
  21. >     It would be nice if [] could work like (), that is one could
  22. > declar
  23. >     operator[](int,int,int){ ...}
  24. > for example, that is, allow multiple arguments for [] just like ().
  25. > This would allow multiple dimensioned matrices as well as providing
  26. > a wealth of extra overloadable notations.
  27. > It would of course break those programs for which
  28. >     a[2,3];
  29. > actually meant a[3] using the comma operator, but there surely are not
  30. > so many of them ..??
  31. Ah yes, one could of course overload the , operator for some sort of 'index' class
  32. and then overload the [] operator using class index as the argument...
  33.  
  34. class index
  35. {
  36. ...
  37.     operator,(int) ...
  38. ...
  39. };
  40.  
  41. class matrix
  42. {
  43. ...
  44.     operator[](index&)
  45. ...
  46. };
  47.  
  48. ---
  49. ---
  50. Paul Andrews
  51.  
  52. EMail        Internal    External
  53. pandrews@lovat    8-727-4723    44-71-975-4723
  54.  
  55.