Topic: +,-,*,/ overloaded operator precedence


Author: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
Date: 1995/05/25
Raw View
The precedence for user-defined operators is exactly the same as for builtin
operators. You can change the behavior but not their precedence and you can't
introduce new operators.

 regards
  Enno

hsc@eng.cam.ac.uk (Hiang-Swee Chiang) writes:
>I have overload the +, -, *, and / operator for my CEmuFloat class.  I am
>wondering about the precedence of these newly overloaded operator.  Do they
>follow the normal precedence, or from left to right or from right to left?
> [ ->*<- ]





Author: hsc@eng.cam.ac.uk (Hiang-Swee Chiang)
Date: 1995/05/24
Raw View
Hello Dear C++ Developer,

I have overload the +, -, *, and / operator for my CEmuFloat class.  I am
wondering about the precedence of these newly overloaded operator.  Do they
follow the normal precedence, or from left to right or from right to left?



Author: mj-perry@ux4.cso.uiuc.edu (Perry Michael James)
Date: 1995/05/24
Raw View
hsc@eng.cam.ac.uk (Hiang-Swee Chiang) writes:

>I have overload the +, -, *, and / operator for my CEmuFloat class.  I am
>wondering about the precedence of these newly overloaded operator.  Do they
>follow the normal precedence, or from left to right or from right to left?

>From my own manual testing, they worked as normal precedence, ie. * and /
>higher than + and -.  However, I want to be absolutely sure.  Can some C++
>guru enlighten me?

You can't change the precedence of operators.  The precedence remains
the same as for the base types.

--
//     "C makes it easy to shoot yourself in the foot.  C++ makes it
//      harder, but when you do, it blows away your whole leg."
//
//                                       -- Bjarne Stroustrup on C++