Question: 9.5 (C++) 9.51 Class) Create a class called for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the
9.5 (C++)


9.51 Class) Create a class called for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form where i is 1 Use variables to represent the data of the class. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in case no initializers are provided. Provide member functions that perform the following tasks: A. add Adds two complex numbers: The real parts are added together and the imaginary parts are added together. B. subtract-Subtracts 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. tostring-Returns a representation of a number in the form , where is the real part and is the imaginary part. In Chapter 10, you'll learn how to overload and so you can write expressions like and and a to add, subtract and output objects. [Note: The C++ Standard Library provides its own class for complexnumber arithmetic. For information on this class, visit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
