complex::real
Ruft die reelle Komponente einer komplexen Zahl ab, oder legt diese fest.
constexpr T real( ) const;
T real(const T& Right);
Parameter
- Right
Eine komplexe Zahl, deren reeller Wert extrahiert werden soll.
Rückgabewert
Der reelle Teil der komplexen Zahl.
Hinweise
Für eine komplexe Zahl a + bi lautet der reelle Teil bzw. die reelle Komponente Re(a + bi) = a.
Beispiel
// 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;
}
Anforderungen
Header: <complex>
Namespace: std