I am trying to write an operator != function that compares if two complex numbers are the same. I Have written an equal to == function which works well but I am trying to use the negation of the result.
bool ComplexNumber::operator !=(ComplexNumber a) {
return !(this==(a)); //the == has been overloaded
}
return !(this==(a));is comparing aComplexNumber*to aComplexNumber. Change to:Also added
constqualifier to function and argument (which I changed to to a reference to avoid unnecessary copy). You will need to addconstqualifier tobool ComplexNumber::operator ==()if it is not already present.