Thu, 08/01/2002 - 18:45
Forums:
Hi, dear all,
In the class gp_XYZ, gp_Vec and gp_Dir etc. the operator ^ has been defined, but if you implement the followed calculation, will result a error, e.g.:
gp_XYZ myXYZ = gp_XYZ( 1., 0., 0.) + gp_XYZ(0.,0.,0.) ^ gp_XYZ(10.,10.,10.);
the result is myXYZ = ( 0., -10., 10.)
Could you someone tell me how to define a operator privilege in C++?
Thanks
Shangjian Du
Fri, 08/02/2002 - 19:32
You cannot change the precedence for overloaded operators in C++. The precedence remains the same as the default operator. In this case addition (+) is higher that bitwise exclusive or (^).
Luckly the language does provide a workaround: use parentheses.