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;
}
需求
標題: <complex>
命名空間: std