共用方式為


complex::imag

擷取一個複數的虛構的元件。

Type imag( ) const;
Type imag(const Type& _Right);

參數

  • _Right
    假想的值代表要擷取的複雜數值。

傳回值

複數的虛數部分。

備註

對於複雜數值 、+ Double、虛構區段或元件是 Im (+ double) = b。

範例

// complex_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 = c1.real ( );
   cout << "The real part of c1 is c1.real ( ) = "
        << dr1 << "." << endl;

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

需求

標題: <complex>

命名空間: std

請參閱

參考

complex Class