Thread View: gnu.g++
1 messages
1 total messages
Started by Naoki Saito, GEO-002, Ext. 5471
Fri, 29 Dec 1989 14:38
Why operator() must be a member?
Author: Naoki Saito, GEO-002, Ext. 5471
Date: Fri, 29 Dec 1989 14:38
Date: Fri, 29 Dec 1989 14:38
24 lines
1100 bytes
1100 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads