imag function - C complex.h

C examples for complex.h:imag

type

public member function

From


<complex>
<complex.h>

std::complex::imag

Prototype

T imag() const;
void imag (T val);

Description

Imaginary part

Return value

The imaginary part. T is complex's template parameter.

Demo Code


#include <iostream>
#include <complex>

int main ()//from w w w  .ja v  a2s .  c  o  m
{
  std::complex<double> mycomplex (20.0,2.0);

  std::cout << "Imaginary part: " << mycomplex.imag() << '\n';

  return 0;
}

Related Tutorials