Index:
[thread]
[date]
[subject]
[author]
From: Robert C. Duvall <rcd@cs.duke.edu>
To :
Date: 01 Feb 1999 13:27:39 -0500
Re: Problem defining negative operator...
> I've been having trouble implementing the negative operator (-).
> I've been following the format of most of the other operators in
> exptree.h and exptree.icc, but the compiler doesn't seem to like
> it no matter how I define it. This is the code I have for it in each
> of the two files:
>
> In exptree.h:
> friend Expression operator- ( );
>
> And in exptree.icc:
> inline Expression operator- ()
> {
> return Expression(new Negative(lhs.MakeNode()));
> }
>
> Am I missing something really obvious, because g++ keeps saying
> things like:
>
> exptree.icc:69: `operator -()' must have an argument of class or
> enumerated type
> exptree.icc:69: `operator -()' must take either one or two arguments
>
> Can anyone help with this one? Thanks!
As the error states, operator - "must take either one or two
arguments". In other words, you need to pass it the value to negate
as a parameter.
In the above code example, where are you getting "lhs" from?
rcd
--
Robert C. Duvall
Lecturer, Duke University
rcd@cs.duke.edu
Index:
[thread]
[date]
[subject]
[author]