operator<< (<complex>)
Visual Studio 2015
Inserts a complex number specified into the output stream.
- _Ostr
The output stream into which the complex number is being entered.
- _Right
The complex number to be entered into the output stream
Writes the value of the specified complex number to the _Ostr in a Cartesian format: ( real part, imaginary part ).
The output stream is overloaded so that it will accept any form of a complex number, and its default output format is the Cartesian format.
Example
// complex_op_insert.cpp // compile with: /EHsc #include <complex> #include <iostream> int main( ) { using namespace std; double pi = 3.14159265359; complex <double> c1 ( 3.0 , 4.0 ); cout << "Complex number c1 = " << c1 << endl; complex <double> c2 ( polar ( 2.0 , pi / 6 ) ); cout << "Complex number c2 = " << c2 << endl; // To display in polar form double absc2 = abs ( c2 ); double argc2 = arg ( c2 ); cout << "The modulus of c2 is: " << absc2 << endl; cout << "The argument of c2 is: "<< argc2 << " radians, which is " << argc2 * 180 / pi << " degrees." << endl << endl; }
Requirements
Header: <complex>
Namespace: std
Show: