Question: Write a complex.h file for this complex.cpp file /** * Implementation for the complex class * @author * * Date: LAST DATE MODIFIED * File:
Write a complex.h file for this complex.cpp file
/** * Implementation for the complex class * @author *
* Date: LAST DATE MODIFIED * File: complex.cpp * Course: * Project #: * Instructor: *
*/
#include
/* SOME FUNCTION HAVE BEEN IMPLEMENTED FOR YOU. IMPLEMENT ALL OTHER FUNCTIONS DESCRIBED ON THE PROJECT HANDOUT. WHOSE PROTOTYPES APPEAR IN THE CLASS. */
Complex::Complex() { real = 0.0; imag = 0.0; }
double Complex::getReal() const { return real; }
Complex Complex::conjugate() const { return Complex(real,-imag); }
friend Complex operator +(const Complex& z1, const Complex& z2) { return Complex(z1.real+z2.real,z1.imag+z2.imag); }
friend ostream& operator
Here are functions to be included.


Your goal in this project is to write the interface and implementation for the complex number class. The public interface for the complex number class should provide the following member functions: 1. constructors: There will be three versions of the constructor function: a. Complex() : the default constructor sets both real and imag, private member variables, to 0 . The default constructor is implemented for you. b. Complex(double r) : the second constructor sets real to r, the double, and imag to 0 . c. Complex(double r, double i) : the third constructor sets real to r and imag to i. 2. operators: +,,/ and will be overloaded as non-member friend functions. For the / operator, when both the real and imaginary parts of the divisor are 0 , an exception occurs. The operator must throw an integer, 1. The
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
