complex class in C++: Types of constructors and operators

To use a complex class header <complex> must be included.


template <class T> class complex

Types of constructors used by complex class:

Type-1: Complex object with real and imaginary components:

complex(const T &r = T( ), const T &i = T( ));

Type-2: Complex class iwth copy of obj.

complex(const complex &obj);

Type-3: Creating complex object from obj:

template <class T> complex(const complex<T> &obj);

Operators used by complex class: +, −, *, /, −=, +=, /=, *=, =, ==, !=.

Leave a Reply