共用方式為


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