Article View: gnu.g++
Article #483operator() must be a member?
From: Naoki Saito, GEO-002, Ext. 5471
Date: Thu, 28 Dec 1989 19:53
Date: Thu, 28 Dec 1989 19:53
24 lines
1096 bytes
1096 bytes
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
Technical Details
Message-ID:
<8912281953.AA28440@ascsu1.SLCS.SLB.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sdrvx2.sinet.slb.com!saitoShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: operator() must be a member? Message-ID: <8912281953.AA28440@ascsu1.SLCS.SLB.COM> Date: 28 Dec 89 19:53:39 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 24