You are on page 1of 2

#include <string>

#include <iostream>
#include "Complex.h" // Complex class definition
using namespace std;

// Constructor
Complex::Complex(double realPart, double imaginaryPart)
: real{realPart}, imaginary{imaginaryPart} { }

// addition operator
Complex Complex::operator+(const Complex& operand2) const {
return Complex{real + operand2.real, imaginary + operand2.imaginary};
}

Complex::bool operator==(const complex& complex,const complex& operand2 )


{
return (real{realPart}==operand2.{realPart});
return (imaginary{imaginaryPart}==operand2.{imaginaryPart});

Complex Complex::bool operator!=(const complex& complex,const complex& operand2)


{
return (real{realPart}!=operand2.{realPart});
return (imaginary{imaginaryPart}!=operand2.{imaginaryPart})
}

// subtraction operator
Complex Complex::operator-(const Complex& operand2) const {
return Complex{real - operand2.real, imaginary - operand2.imaginary};
}

// return string representation of a Complex object in the form: (a, b)


string Complex::toString() const {
return "(" + to_string(real) + ", " + to_string(imaginary) + ")";
}

int main() {
Complex complex(2,3);
Complex operand2(3,5);

if(complex.real == operand2.real)&&(complex.real ==operand2.real)


operator==(complex,operand2)
{
toString()<<endl;
}
else{operator!=(complex,operand2)
toString()<<endl;
}

complex.toString()

You might also like