cplusplus.com
C++ : Reference : Miscellaneous : complex : complex : real
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
complex
abs
arg
complex
conj
cos
cosh
exp
imag
log
log10
norm
polar
pow
real
sin
sinh
sqrt
tan
tanh
complex
complex::complex
complex operators
member functions:
complex::imag
complex::real
member types:
complex::value_type


complex::real

public member function
T real() const;

Return real part

Returns the real part of the complex number.

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

Parameters

none

Return value

Real part.
T is complex's template type.

Example

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

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

  cout << "Real part: " << mycomplex.real() << endl;

  return 0;
} 


Output:

Real part: 10

See also