C++ Complex Library - Real


Advertisements

Description

It is used to real part of complex and returns the real part of the complex number x.

Declaration

Following is the declaration for std::real.

template<class T> T real (const complex<T>& x);

C++11

template<class T> T real (const complex<T>& x);

Parameters

x − It is a complex value.

Return Value

It returns the real part of the complex number x.

Exceptions

none

Example

In below example for std::real.

#include <iostream>     
#include <complex>      

int main () {
   std::complex<double> mycomplex (50.0,1.0);
   std::cout << "Real part is: " << std::real(mycomplex) << '\n';
   return 0;
}

The sample output should be like this −

Real part is: 50
complex.htm
Advertisements