Re: A question about operator overloading?
On Thu, 6 Dec 2007 07:00:20 -0800 (PST) in comp.lang.c++, dolphin
<jdxyw2004@gmail.com> wrote,
>Why the operator-() should not be a member function? Can someone give
>a example?
#include <complex>
int main()
{
std::complex<double> v(0.5);
v - 1.0; // works whether or not - is a member
1.0 - v; // Works only if - is a non-member.
}
|