Standard C++ Library Reference ISO/IEC (VERSION3)

complex& operator*=(const complex<Other>& right);
template<class Other>
complex& operator/=(const complex<Other>& right);
complex& operator=(const Ty& right);
complex& operator+=(const Ty& right);
complex& operator-=(const Ty& right);
complex& operator*=(const Ty& right);
complex& operator/=(const Ty& right);
};
The template class describes an object that stores two objects of type Ty, one that represents the
real part of a complex number and one that represents the imaginary part. An object of class Ty:
has a public default constructor, destructor, copy constructor, and assignment operator --
with conventional behavior
can be assigned integer or floating-point values, or type cast to such values -- with
conventional behavior
defines the arithmetic operators and math functions, as needed, that are defined for the
floating-point types -- with conventional behavior
In particular, no subtle differences may exist between copy construction and default
construction followed by assignment. And none of the operations on objects of class Ty may
throw exceptions.
Explicit specializations of template class complex exist for the three floating-point types. In
this implementation, a value of any other type Ty is type cast to double for actual calculations,
with the double result assigned back to the stored object of type Ty.
complex::complex
complex(const Ty& realval = 0, const Ty& imagval = 0);
template<class Other>
complex(const complex<Other>& right);
The first constructor initializes the stored real part to realval and the stored imaginary part to
imagval. The second constructor initializes the stored real part to right.real() and the
stored imaginary part to right.imag().
In this implementation, if a translator does not support member template functions, the
template:
template<class Other>
complex(const complex<Other>& right);
is replaced by:
complex(const complex& right);