Hi,
I'm trying to format a number input as:
(12345.35,-55) (-3,34567.99)
to produce this output:
The Complex numbers are: (+ 12345.35,- 55.00) and (- 3.00,+ 34567.99)
Here is my overloaded << operator:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// overloads the binary "<<" operator through a global friend function
// Complex object will be formatted in the following format:
// ( -125.00, 23.44 )
ostream & operator << (ostream & dest, const Complex & obj)
{
dest << fixed << setprecision(2);
if( obj.real_part > 0 )
{
dest << "(+ ";
}
else
{
dest << "( ";
}
dest << obj.real_part << ", " << obj.imaginary_part << " )";
return dest; // enables cout << a << b << c
}
|
I need the output of flags to be:
The cout format flags are set to: 1537
The cout format flags are set to: 513
Instead of what I'm getting:
The cout format flags are set to: 9729
The cout format flags are set to: 8705
The code for this is:
1 2 3 4 5 6 7
|
newFormat = cout.flags(); //find out how flags are set now
cout << "\nThe cout format flags are set to: " << newFormat << endl;
newFormat &= ~ios::oct; // Ensure oct bit is NOT set
// Mode is now "nnnn.nn nnnn.nni"
cout.flags(newFormat);
cout << "\nThe cout format flags are set to: " << newFormat << endl;[code]
|
Thanks,
Sean