C++ <complex> - operator+ Function
The C++ <complex> operator+ function is used to apply unary plus operator to a complex number.
Syntax
template<class T> complex<T> operator+ (const complex<T>& rhs);
Parameters
rhs |
Specify right-hand side complex number. |
Return Value
Returns a new complex number as a result of performing operation.
Example:
The example below shows the usage of operator+ function.
#include <iostream> #include <complex> using namespace std; int main (){ complex<double> z1 (10, 20); complex<double> z2; //result of +z1 is stored in z2 z2 = +z1; //displaying the result cout<<"z1 : "<<z1<<"\n"; cout<<"z2 : "<<z2<<"\n"; return 0; }
The output of the above code will be:
z1 : (10,20) z2 : (10,20)
❮ C++ <complex> Library