template<class Type> class complex
The template class describes an object that stores two objects of type Type, one that represents the real part of a complex number and one that represents the imaginary part. An object of class Type:
- 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. None of the operations on objects of class Type 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 Type is typecast to double for actual calculations, with the double result assigned back to the stored object of type Type