home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!think.com!ames!decwrl!decwrl!world!tob
- From: tob@world.std.com (Tom O Breton)
- Subject: Re: operator [][]
- Message-ID: <BxGtCK.91t@world.std.com>
- Organization: The World Public Access UNIX, Brookline, MA
- References: <BxFt8r.2Kt@cs.columbia.edu> <1992Nov9.095352.19114@fmrco.uucp>
- Date: Mon, 9 Nov 1992 20:09:56 GMT
- Lines: 42
-
-
-
- That is one approach to operator[] for multiple arrays. I have another which:
-
- 0: has the advantage of not requiring intermediate array classes of lesser
- dimensions.
-
- 1: has the disadvantage of requiring another class.
-
- 2: has the property of being suited to multiple arrays that always totally
- de-array(?) themselves, and unsuited to arrays that might deal with
- intermediate sub-arrays.
-
- Instead of
-
- operator[](int index)
-
- make this class:
-
- struct indices //Struct because it's going to be all open.
- { int index1;
- int index2;
- indices(int,int);
- };
-
- and use it as the argument:
-
- class MultArray
- { operator[](indices IXs); }
-
- You can call it concisely with:
-
- //MultArray A;
- A[indices(x,y)];
-
- Tom
-
-
-
- --
- The Tom spreads its huge, scaly wings and soars into the wild sky...
- up... up... out of sight... (tob@world.std.com)
-