subject

Rewrite the definition of the class complexType so that the arithmetic and relational operators are overloaded as nonmember functions. Write a test program that tests various operations on the class complexType. Format your answer with two decimal places. complexType. h//Specification file complexType. h#ifndef H_complexNumber#define H_complexNumber#include using namespace std;class complexType{// overload stream insertion and extraction operatorsfriend ostream& operator<< (ostream&, const complexType&);friend istream& operator>> (istream&, complexType&);friend complexType operator+(const complexType& one, const complexType& two);//overload +friend complexType operator*(const complexType& one, const complexType& two);//overload *friend complexType operator-(const complexType& one, const complexType& two);//overload -friend complexType operator/(const complexType& one, const complexType& two);//overload /friend bool operator==(const complexType& one, const complexType& two);//overload ==public:void setComplex(const double& real, const double& imag);//Function to set the complex number according to the parameters//Postcondition: realPart = real; imaginaryPart = imagvoid getComplex(double& real, double& imag) const;//Function to retrieve the complex number.//Postcondition: real = realPart; imag = imaginaryPartcomplexType(double real = 0, double imag = 0);//constructorprivate:double realPart; // variable to store the real partdouble imaginaryPart; // variable to store the imaginary part};complexType. cpp//Implementation file complexType. cpp#include #include "complexType. h"using namespace std;ostream& operator<< (ostream& os, const complexType& complex){os << "(" << complex. realPart << ", "<< complex. imaginaryPart << ")";return os;}istream& operator>> (istream& is, complexType& complex){char ch;is >> ch; //read and discard (is >> complex. realPart; //get the real partis >> ch; //read and discard, is >> complex. imaginaryPart; //get the imaginary partis >> ch; //read and discard)return is;}bool complexType::operator==(const complexType& otherComplex) const{return(realPart == otherComplex. realPart &&imaginaryPart == otherComplex. imaginaryPart);}//constructorcomple xType::complexType(double real, double imag){realPart = real;imaginaryPart = imag;}void complexType::setComplex(const double& real, const double& imag){realPart = real;imaginaryPart = imag;}void complexType::getComplex(double& real, double& imag) const{real = realPart;imag = imaginaryPart;}//overload the operator +complexType complexType::operator+(const complexType& otherComplex) const{complexType temp;temp. realPart = realPart + otherComplex. realPart;temp. imaginaryPart = imaginaryPart + otherComplex. imaginaryPart;return temp;}//overload the operator *complexType complexType::operator*(const complexType& otherComplex) const{complexType temp;temp. realPart = (realPart * otherComplex. realPart) -(imaginaryPart*otherComplex. imaginaryPart);temp. imaginaryPart = (realPart * otherComplex. imaginaryPart) +(imaginaryPart * otherComplex. realPart);return temp;}complexType complexType::operator-(const complexType& otherComplex) const{complexType temp;temp. realPart = realPart - otherComplex. realPart;temp. imaginaryPart = imaginaryPart - otherComplex. imaginaryPart;return temp;}complexType complexType::operator/(const complexType& otherComplex) const{complexType temp;double denominator;if (otherComplex. realPart == 0 && otherComplex. imaginaryPart == 0){cout << "Cannot divide by zero" << endl;return otherComplex;}else{denominator = otherComplex. realPart * otherComplex. realPart +otherComplex. imaginaryPart * otherComplex. imaginaryPart;temp. realPart = ((realPart * otherComplex. realPart) +(imaginaryPart * otherComplex. imaginaryPart)) /denominator ;temp. imaginaryPart = ((- realPart * otherComplex. imaginaryPart) +(imaginaryPart * otherComplex. realPart)) /denominator;return temp;}}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
Modern businesses use different technologies to accomplish work tasks
Answers: 2
question
Computers and Technology, 24.06.2019 11:40
100 pts. first person gets brainliest
Answers: 2
question
Computers and Technology, 24.06.2019 16:30
What is the item which could be matched with a statement below? software installed on a computer that produces pop-up ads using your browser an example of social engineering malware loads itself before the os boot is complete type of spyware that tracks your keystrokes, including passwords windows key + l the practice of tricking people into giving out private information or allowing unsafe programs into the network or computer when someone who is unauthorized follows the employee through a secured entrance to a room or building a type of malware that tricks you into opening it by substituting itself for a legitimate program a computer that has been hacked, and the hacker is using the computer to run repetitive software in the background without the user's knowledge an infestation designed to copy itself repeatedly to memory, on drive space, or on a network
Answers: 1
question
Computers and Technology, 25.06.2019 04:10
This might be a bit off-topic, but i'm having trouble with a certain arg made by game theory. if there are any theorists out there that wanna , it would be appreciated!
Answers: 2
You know the right answer?
Rewrite the definition of the class complexType so that the arithmetic and relational operators are...
Questions
Questions on the website: 13722363