Mail Archives: djgpp/1997/07/12/21:18:08
SWars Matt wrote:
> I had also defined a ^ operator of a complex
> number and an integer. The compiler told me that for the +, -, and *
> operator there must be either one or zero arguments, and for / and ^
> there
> must be exactly one. Why is this? I don't understand why I am limited
> to
> the number of arguments.
This error is given when you are attempting to declare an overloaded
operator that is a member function.
That is:
class C
{
// ...
operator +(int x);
friend operator +(C &c, double y);
// ...
};
C c;
c + 2; // calls C::operator +(int) -- the member function
c + 1.; // calls operator +(C &, double) -- the friend function
In other words, I suspect that what you said earlier (namely that you were
declaring them as friend functions) is wrong.
For more help, you'll have to post (the shortest amount of) code that
exhibits the problem.
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"All the gods are dead / except the god of war."
/ Eldridge Cleaver
- Raw text -