operators computing direction
- by amiad
Hi all!
I enqunterd something that I can't understand.
I have this code:
cout << "f1 * f1 + f2 * f1 - f1 / f2 is: "<< f1 * f1 + f2 * f1 - f1 / f2 << endl;
All the "f"s are objects, and all the operators are overloaded.
The weird this is that the first computarion is of the "/" operator,
then the second "" and then the first "", after that - the operator "+" and at last - operator "-".
So basicly - the "/" and "*" worked from right to left,
and the "+" and "-" operators worked from left to right.
I made another test...
I checked this code:
cout << "f1 * f1 / f2 is: " << f1 * f1 / f2 << endl;
Now, the first operator was "*" and only then oerator "/".
So now, it worked from left to right.
Can someone help me underatand why is there diffrence in the directions?
10X!