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