From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Newbie question: Help with complex class Date: Sat, 12 Jul 1997 13:11:06 -0700 Organization: Alcyone Systems Lines: 43 Message-ID: <33C7E4DA.6902B8C7@alcyone.com> References: <19970711213301 DOT RAA26434 AT ladder01 DOT news DOT aol DOT com> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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