home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!fmrco!pandrews!pandrews
- From: pandrews@lovat.fmrco.com (Paul Andrews)
- Subject: Re: operator [][]
- Message-ID: <1992Nov12.094813.28366@fmrco.uucp>
- Sender: news@fmrco.uucp
- Reply-To: pandrews@lovat.fmrco.com
- Organization: Fidelity Investments Ltd.
- References: <1992Nov11.182016.13511@ucc.su.OZ.AU>
- Date: Thu, 12 Nov 1992 09:48:13 GMT
- Lines: 48
-
- In article 13511@ucc.su.OZ.AU, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- > In article <1992Nov9.114516.29846@alf.uib.no> s026@brems.ii.uib.no (Paal K Holmberg) writes:
- > >In article <1992Nov9.095352.19114@fmrco.uucp>, pandrews@lovat.fmrco.com (Paul Andrews) writes:
- > >|>
- > >since it os a trouble to get around mutiple []'s , you can always cheat and use a
- > >normal function element(int x,int y...) to get a certain element in the matrix or whatever.
- > >I agree it is not as elgant as the [] approach, but it is easy.
- > >
- >
- > It would be nice if [] could work like (), that is one could
- > declar
- >
- > operator[](int,int,int){ ...}
- >
- > for example, that is, allow multiple arguments for [] just like ().
- > This would allow multiple dimensioned matrices as well as providing
- > a wealth of extra overloadable notations.
- >
- > It would of course break those programs for which
- >
- > a[2,3];
- >
- > actually meant a[3] using the comma operator, but there surely are not
- > so many of them ..??
- Ah yes, one could of course overload the , operator for some sort of 'index' class
- and then overload the [] operator using class index as the argument...
-
- class index
- {
- ...
- operator,(int) ...
- ...
- };
-
- class matrix
- {
- ...
- operator[](index&)
- ...
- };
-
- ---
- ---
- Paul Andrews
-
- EMail Internal External
- pandrews@lovat 8-727-4723 44-71-975-4723
-
-