Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!ftpbox!motsrd!motcid!stephens From: stephens@motcid.UUCP (Kurt Stephens) Newsgroups: comp.lang.c++ Subject: Re: Matrix Class Libraries Message-ID: <6732@celery34.UUCP> Date: 19 Mar 91 18:32:35 GMT References: <13505@darkstar.ucsc.edu> <1991Mar18.025539.18998@athena.mit.edu> Organization: Motorola Inc., Cellular Infrastructure Div., Arlington Heights, IL Lines: 36 Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes: >In article <1991Mar18.025539.18998@athena.mit.edu> bjaspan@athena.mit.edu (Barr3y Jaspan) writes: >>class Matrix { > ... >> inline double& operator()(int, int) const; > ... >>}; >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]. Just define: inline double* Matrix::operator [](int i) { return Row(i); } Matrix M; double d; d = M[1][2]; "M[1]" evals to a double*, right? The "[2]" indexes off the double*. KISS (Keep It Simple Stephens) ;^) -- Kurt A. Stephens Foo::Foo(){return Foo();} stephens@void.rtsg.mot.com "When in doubt, recurse."