Hey guys ., this is urgent; so i need help with my code ; well i have to Create a class called Complex for performing arithmetic with complex numbers.
Write a driver program to test your class. Complex numbers have the form:
realPart + imaginaryPart * i
where i is the square root of -1
Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided. Provide public member functions for each of the following:
a) Addition of two Complex numbers: The real parts are added together and the imaginary parts are added together.
b) Subtraction of two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand and the imaginary part of the right operand is subtracted from the imaginary part of the left operand.
c) Printing Complex numbers in the form (a, b) where a is the real part and b is the imaginary part
I'm not sure if the class is write. And if possible can i be provided with a driver program
Issues #2 and #3 still exist. comp_add and comp_subt compute r and i but the values are lost when the functions exit.
As for a driver program, that is part of your homework and I won't do your homework for you. I will tell you that a driver program is nothing more than a main that instantiates a few complex numbers and performs some operations on them.
You might want to consider overloading the + and - and << operators. This will allow you to use complex numbers in a very intuitive way.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.