Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!bjaspan From: bjaspan@athena.mit.edu (Barr3y Jaspan) Newsgroups: comp.lang.c++ Subject: Re: Matrix Class Libraries Message-ID: <1991Mar18.213545.20966@athena.mit.edu> Date: 18 Mar 91 21:35:45 GMT Article-I.D.: athena.1991Mar18.213545.20966 References: <13505@darkstar.ucsc.edu> <1991Mar18.025539.18998@athena.mit.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 26 In article , Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes: |> I think this points out one problem in C++. You really should be able to |> say: |> inline double& operator[][](int, int) const; |> |> The problem isn't very serious, but it just isn't natural to access array |> members using notation array(x,y), but array[x][y]. At the risk of starting a religous war, I'll respond. :-) In this particular case, the first method is preferable. Being able to say array[x][y] implies (in the conventional C style) that array[x] is meaningful (it always is in C). For my Matrix class, it isn't meaningful (you could argue that I should have derived Matrix from Vector, in which case array[x] could be meaningful, but that isn't the point.) So if you really always wanted to use [] for array indexing and () only for function calls, [] would have to accept any number and type of arguments (ie: operator[](int, int).) But then it would be semantically identical to () anyway, so what's the point? In any case, I agree that it isn't a serious problem. -- Barr3y Jaspan, bjaspan@mit.edu Watchmaker Computing