public member function
<complex>

std::complex::real

T real() const;
get (1)
T real() const;
set (2)
void real (T val);
Real part
Returns the real part of the complex number.
Returns the real part of the complex number (1), or sets val as the new value for the real part (2).

A non-member function exists with the same name: real.

Parameters

none

Return value

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

Example

1
2
3
4
5
6
7
8
9
10
11
12
// complex::real example
#include <iostream>     // std::cout
#include <complex>      // std::complex

int main ()
{
  std::complex<double> mycomplex (10.0,1.0);

  std::cout << "Real part: " << mycomplex.real() << '\n';

  return 0;
}


Output:

Real part: 10

See also