次の方法で共有


imag

複雑なコンポーネントの虚数部を抽出します。

template<class Type>
   Type imag(
      const complex<Type>& _ComplexNum
   );

パラメーター

  • _ComplexNum
    実数部が配置される複素数。

戻り値

グローバル関数として、複素数の部分。

解説

このテンプレート関数は、複素数の実数部を変更することはできません。実数部を変更するには、新しい複合型は構成値を割り当てる必要があります。

使用例

// complexc_imag.cpp
// compile with: /EHsc
#include <complex>
#include <iostream>

int main( )
{
   using namespace std;
   complex <double> c1 ( 4.0 , 3.0 );
   cout << "The complex number c1 = " << c1 << endl;

   double dr1 = real ( c1 );
   cout << "The real part of c1 is real ( c1 ) = "
        << dr1 << "." << endl;

   double di1 = imag ( c1 );
   cout << "The imaginary part of c1 is imag ( c1 ) = "
        << di1 << "." << endl;
}
  
  

必要条件

ヘッダー: <complex>

名前空間: std