Question
Create a class Complex having two private data members real and imag of type double. The declaration of your class (.h file) should include into
Create a class Complex having two private data members real and imag of type double. The declaration of your class (.h file) should include into the public section the prototypes of two constructors (default non- parameterized and constructor initializer), as well as the following member functions getReal, getImag, setReal, setImag, addComplex, subtractComplex, multiplyComplex and print. The last one displays the values stored into the private data members. Additional Requirements: 1. Use minimum number of formal parameters. 2. For the definition of the constructor initializer use the initialization list. 3. For the definitions of addComplex, subtractComplex and multiplyComplex use pointer this. Write a driver (.cpp) program to test all of the above functions. Submit printout of your source code and your outputs. NOTE: You should create three separate files (.h file for class declaration; .cpp file for member function definitions and .cpp file for driver program).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started