##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::complex::operator=

From cppreference.com
< cpp‎ | numeric‎ | complex

complex<T>& operator=( const T& x ); | (1) |
template< class X > complex<T>& operator=( const complex<X>& cx ); | (2) |

Assigns new values to the contents.

1) Assigns `x` to the real part of the complex number. Imaginary part is set to zero.
2) Assigns `cx.real()` and `cx.imag()` to the real and the imaginary parts of the complex number respectively.

### [edit] Parameters

x | - | value to assign
cx | - | complex value to assign

### [edit] Return value

*this

### [edit] See also

(constructor) | constructs a complex number (public member function) [edit]
operator""if operator""i operator""il (C++14) | A std::complex literal representing pure imaginary number (function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/numeric/complex/operator%3D&oldid=77764"