help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with operator%


From: Mike Wahler
Subject: Re: help with operator%
Date: Thu, 20 Oct 2005 02:54:26 GMT

"Al-Burak" <jalqadir@netscape.net> wrote in message 
1129773505.133834.286680@g43g2000cwa.googlegroups.com">news:1129773505.133834.286680@g43g2000cwa.googlegroups.com...
> In the program
> --- money.hpp
> namespace jme{
>   class Money{
>      protected: float amount;
>      ...
>      public: friend jme::Money jme::operator%( jme::Money&,
> jme::Money&);
> };
> }
> --- money.cpp
> jme::Money jme::operator%(jme::Money& lhs, jme::Money& rhs){
>   jme::Money tmp;
>   return tmp = lhs.amount % rhs.amount;
> }
>
> I get an error message, that reads:
> Project   : Money
> Compiler  : GNU GCC Compiler (called directly)
> Directory : c:\money\
> --------------------------------------------------------------------------------
> Switching to target: default
> Compiling: money.cpp
> money.cpp: In function `jme::Money jme::operator%(jme::Money&,
> jme::Money&)':
> money.cpp:72: error: invalid operands of types `float' and `float' to
> binary `operator
> --------------------------------------------------------------------------------
> What am I doing wrong?

Your compiler just told you: you're trying to use
an operator with a type for which it's not valid.

-Mike




reply via email to

[Prev in Thread] Current Thread [Next in Thread]