Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sdrvx2.sinet.slb.com!saito From: saito@sdrvx2.sinet.slb.com (Naoki Saito, GEO-002, Ext. 5471) Newsgroups: gnu.g++ Subject: Why operator() must be a member? Message-ID: <8912291438.AA01110@ascsu1.SLCS.SLB.COM> Date: 29 Dec 89 14:38:05 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 24 Hi! I have a sort of vector class. I want to define inner product (or so-called dot product) using operator() as follows: friend float operator()(vector a, vector b) { if (a.size() != b.size()) error("Vector sizes are different!"); float res = 0.0; for (i = 0; i < a.size(); i++) res += a[i]*b[i]; return res; } Although g++-1.34.2 successfully compiled this(no complaint), Sun C++ 2.0 produced an error as follows: error: operator() must be a member g++-1.36.x compiles this or behaves as the Sun C++? Why does AT&T 2.0 restrict the usage of the operator()? Regards, Naoki Saito (saito@sdr.slb.com) Schlumberger-Doll Research