I'm writing a program for complex number computations and trying to overload the ++ and <<. I'm having a problem and I really don't know if it is with << or ++. My code is:
So does the evaluation depend upon which compiler am I using? Also the values I get are something totally different. Ex if the complex number is 8+i0 then instead of getting 8 or 9 i get something like 6.xxxx +i3.xxxx. So I really cannot understand why it happens so when it works just fine with separated computations.
I changed the function as suggested by you and copied all the codes in a new project and now it is behaving good. However for the line: cout << " Val: " << c10 << " ++c increment " << ++c10 << " c++ increment " << c10++; the operations are being executed from right to left. Any suggestions how I could make it work from left to right.
Any suggestions how I could make it work from left to right.
Nope, sorry.
You should just avoid modifying data while also displaying it... while also modifying it. As the link above shows, this is a stream issue, and also your overloaded operators are fine. So even if you wanted to fix the problem, it wouldn't be your problem to fix.