complex::real
获取或设置一个复数的实际组件。
Type real( ) const;
Type real(const Type& _Right);
参数
- _Right
实际值将提取的一个复数。
返回值
复数的实部。
备注
对于一个复数 +二进制文件、一个实部或元素 有关(+二进制文件) = "。
示例
// complex_class_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 = 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