Thursday, July 30, 2009

Can anyone point me in the right direction on this C++ assignment?

Write a class named Complex that manages


complex numbers


Use the variable r to represent the real part


and the variable x to represent the imaginary part


of the complex number





The class should have a default constructor that


initializes the r to 1.0 and the x to 0.0 if no


argumements are supplied to the constructor





The class should define setter and getter


functions for the class member variables


The setter and getter functions should be inlined


(or at least request compiler to inline)





Values of r less than 0.0 or 0


greater than 100.0 should not be allowed





The class should overload the + operator to add


complex numbers





The class should overload the %26lt;%26lt; operator to


write the class members out to the screen





Write a program that creates objects of type


complex and in the program test all member


functions of the class

Can anyone point me in the right direction on this C++ assignment?
That is lot of work, may be you can contact a C++ expert at website like http://askexpert.info/ .
Reply:I suggest you start with the %26lt;%26lt; operator. That way, you can use it to debug your other operations.





Also, you can use cout in the class to handle pre- and post conditions. It will help you know where you are in your code.





Best of luck, and when you get a working class going, feel free to show it off.
Reply:XD I remember doing this assignment.





Make a class called Complex.





variables for real and imaginary numbers





A default constructor //takes no parameters


Construction with parameters.





overload the operator+





And for overloading the print.





You do the real " + " imaginary "i".


No comments:

Post a Comment