共用方式為


real

擷取一個複數真正的元件。

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

參數

  • _ComplexNum
    實作內部代表要擷取的複數。

傳回值

複數的內部實做為全域函式。

備註

這個函式樣板不能用來修改這個複數的實數部分 若要變更執行內部,必須指定新的複數元件值。

範例

// complex_real.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