public member function

std::complex::imag

<complex>
T imag() const;
Return imaginary part
Returns the imaginary part of the complex number.
The imaginary part is the factor by which the imaginary unit is multiplied.

A global function exists, imag, with the same behavior.

Parameters

none

Return value

Imaginary part.
T is complex's template type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
// complex::imag example
#include <iostream>
#include <complex>
using namespace std;

int main ()
{
  complex<double> mycomplex (20.0,2.0);

  cout << "Imaginary part: " << mycomplex.imag() << endl;

  return 0;
} 


Output:

Imaginary part: 2

See also