Hello guys :)
I hope you are having a great sunday!! :)
I have a c++ homework for tommorrow that i have been working on all day :/
Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form: realPart + imaginaryPart * i
So, This class has two data members: realPart, imaginaryPart (your data members should be of type double)
Provide also the following member functions:
A constructor with no arguments that initializes realPart and imaginaryPart to zero.
An overloaded constructor with arguments.
The “Norm” function that computes and returns the norm of a complex number:
The norm of realPart + imaginaryPart * i is
sqrt(realPart2 + imaginaryPart2)
A “Print” function that prints on the screen a complex number as follows:
If realPart=2 and imaginaryPart=3 it should print: (2 + 3i )
An “add” function that adds two complex numbers: the real parts are added together and the imaginary parts are added together. It will be used as follows:
Complex c(3,6);
Complex d(1,3);
Complex e;
e.add(c,d); // e should become (4,9) after this statement
Write a client program (main function) which creates objects of class Complex and test all your member functions.
here is my work:
but it is keeping giving errors!! :/ anyone can help me please? due date is tomorrow..
#include<iostream>
#include<math.h>
using namespace std;
class Complex {
private:
double realPart ;
double imaginaryPart ;
One of the rules is don't post homework. If you have a specific question that prevents you from doing that homework, lets say syntax of something, then you can ask only that specific question. Not your entire assignment.