saito@sdrvx2.sinet.slb.com (Naoki Saito, GEO-002, Ext. 5471) (12/29/89)
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