```
#include <iostream>
#include <iomanip>
#include <cstdio>
class ComplexNumbers
{
private:
double realpart;
double imagpart;
public:
//Default constructor - set realpart = 0.0, imagpart = 0.0
ComplexNumbers ();
//Initializing constructor - realpart = a, imagpart = b
ComplexNumbers (double a, double b);
//Transformer - Gets complex numbers
void GetComp();
//Transformer - Adds two complex numbers together and returns their sum
ComplexNumbers AddComp (const ComplexNumbers&, const ComplexNumbers&);
//Transformer - Subract two complex numbers from each other and returns their difference
ComplexNumbers SubComp (const ComplexNumbers&, const ComplexNumbers&);
//Transformer - Multiplies two complex numbers together and returns their product
ComplexNumbers MultComp (const ComplexNumbers&, const ComplexNumbers&);
//Transformer - Divides two complex numbers and returns their XXXXX
ComplexNumbers DivComp (const ComplexNumbers&, const ComplexNumbers&);
//Transformer - Calculates the absolute value of two complex numbers and returns their XXXXX
ComplexNumbers AbsComp (const ComplexNumbers&, const ComplexNumbers&);
//Informer - displays a number as n' m"
void ShowComp();
};
using namespace std;
int main()
{
ComplexNumbers numb1, numb2(1, 1);
cout << "\n\nNumb1 default constructor values: \n";
numb1.ShowComp();
cout << "\n\nChange numb1 values: \n";
numb1.GetComp();
cout << "\n\nNumb2 initialized constructor values: \n";
numb2.ShowComp();
cout << "\n\nThe sum of Numb1 and Numb2: \n";
ComplexNumbers sumComp;
sumComp = sumComp.AddComp (numb1, numb2);
sumComp.ShowComp();
cout << "\n\nThe difference of Numb1 and Numb2: \n";
ComplexNumbers diffComp;
diffComp = diffComp.SubComp (numb1, numb2);
diffComp.ShowComp();
cout << "\n\nThe product of Numb1 and Numb2: \n";
ComplexNumbers prodComp;
prodComp = prodComp.MultComp (numb1, numb2);
prodComp.ShowComp();
cout << "\n\nThe XXXXXXXXXXX of Numb1 and Numb2: \n";
ComplexNumbers sepComp;
sepComp = sepComp.DivComp (numb1, numb2);
sepComp.ShowComp();
cout << "\n\nThe absolute value of Numb1 and Numb2: \n";
ComplexNumbers avalComp;
avalComp = avalComp.AbsComp (numb1, numb2);
avalComp.ShowComp();
return 0;
}
ComplexNumbers::ComplexNumbers()
{
realpart = 0.0; imagpart = 0.0;
}
ComplexNumbers::ComplexNumbers( double a, double b)
{
realpart = a; imagpart = b;
}
void ComplexNumbers::GetComp ()
{
cout << "\nEnter realpart: "; cin >> realpart;
cout << "\nEnter imagpart: "; cin >> imagpart;
}
void ComplexNumbers::ShowComp()
{
cout << setw(3) << realpart << "\'"
<< setw(3) << imagpart << '\"';
}
ComplexNumbers::AddComp (const ComplexNumbers& N1, const ComplexNumbers& N2)
{
ComplexNumbers T;
T.realpart = N1.realpart + N2.realpart;
T.imagpart = N1.imagpart + N2.imagpart;
return T;
}
ComplexNumbers::SubComp (const ComplexNumbers& N1, const ComplexNumbers& N2)
{
ComplexNumbers T;
T.realpart = N1.realpart - N2.realpart;
T.imagpart = N1.imagpart - N2.imagpart;
return T;
}
```