Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(void) {
- ComplexNumber num1;
- ComplexNumber num2(1, 2);
- ComplexNumber num3(2, 3);
- cout << "CONSTRUCTOR FUNCTIONS\n";
- cout << "Printing default initialized number. Expecting 0 + 0i: " << num1 << endl;
- cout << "Printing manually initialized number. Expecting 1 + 2i: " << num2 << endl;
- cout << "\nGET FUNCTIONS\n";
- cout << "Getting imaginary part of 2 + 3i. Expecting 3: " << num3.getImaginary() << endl;
- cout << "Getting real part of 2 + 3i. Expecting 2: " << num3.getReal() << endl;
- cout << "\nSET FUNCTIONS\n";
- num1.setReal(4);
- cout << "Setting real part of 0 + 0i to 4. Expecting 4 + 0i: " << num1 << endl;
- num1.setImaginary(6);
- cout << "Setting imaginary part of 4 + 0i to 6. Expecting 4 + 6i: " << num1 << endl;
- cout << "\nELEMENTARY OPERATIONS\n";
- cout << "Printing (1 + 2i) + (2 + 3i). Expecting 3 + 5i: " << (num2 + num3) << endl;
- cout << "Printing (2 + 3i) - (1 + 2i). Expecting 1 + 1i: " << (num3 - num2) << endl;
- cout << "Printing (1 + 2i) * (2 + 3i). Expecting -4 + 7i: " << (num2 * num3) << endl;
- cout << "Printing !(1 + 2i). Expecting 1 - 2i: " << !num2 << endl;
- cout << "Printing (4 + 6i) / (2 + 3i). Expecting ~2: " << num1 / num3 << endl;
- return 0;
- }
- ComplexNumber ComplexNumber::operator!() {
- ComplexNumber conjugate;
- conjugate.real = real;
- conjugate.imaginary = !imaginary;
- return conjugate;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement