operator<< (<complex>)

复数指定插入到输出流。

template<class Type, class Elem, class Traits> 
   basic_ostream<Elem, Traits>& 
      operator<< ( 
         basic_ostream<Elem, Traits>& _Ostr, 
         const complex<Type>& _Right 
      );

参数

  • _Ostr
    复数输入的输出流。

  • _Right
    将进入的复数到输出流

返回值

写入指定的复数的值到解决格式的 _Ostr :( 实部和虚部, )。

备注

输出流重载,以便它接受它的所有形式,因此,默认输出格式是解析格式。

示例

// 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;
}
  

要求

复杂页眉: <>

命名空间: std