C++ has a class complex in its standard template library (STL). The standard usage in a given function could then look like
// Program to calculate addition and multiplication of two complex numbers
using namespace std;
#include <iostream>
#include <cmath>
#include <complex>
int main()
{
complex<double> x(6.1,8.2), y(0.5,1.3);
// write out x+y
cout << x + y << x*y << endl;
return 0;
where we add and multiply two complex numbers x=6.1+ı8.2 and y=0.5+ı1.3 with the obvious results z=x+y=6.6+ı9.5 and z=x⋅y=−7.61+ı12.03.