complex::imag
Extrahiert die imaginäre Komponente einer komplexen Zahl.
Syntax
T imag( ) const;
T imag(const T& _Right);
Parameter
- _Right
Eine komplexe Zahl, deren imaginärer Wert extrahiert werden soll.
Rückgabewert
Der imaginäre Teil der komplexen Zahl.
Hinweise
Für eine komplexe Zahl a + bi lautet der imaginäre Teil bzw. die imaginäre Komponente Im(a + bi) = 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;
}
Die komplexe Zahl ist c1 = (4,3) Der reelle Teil von c1 ist c1.real ( ) = 4.Der imaginäre Teil von c1 ist c1.imag ( ) = 3.
Anforderungen
Header: <complex>
Namespace: std