The standard library provides a complex number type that encapsulates both the real and imaginary parts of a complex number. All arithmetic operators are overloaded to cater for the complex type:
#include<iOStream>
#include<complex>
int main()
{
std::complex<double> c {3.14, 4.2}, d {2.1, -1.2};
std::cout << c + d << std::endl;
}
Copyright © 2026 eLLeNow.com All Rights Reserved.