( Modify ) Modify the main ( ) function in Program to create a third complex num
ID: 3775676 • Letter: #
Question
(Modify) Modify the main( ) function in Program to create a third complex number, 5.3 + 8.4i. Have the program display this new complex number
#include <iostream>
using namespace std;
// declaration section
class Complex
{
private:
double realPart; // declare realPart as a double variable
double imaginaryPart; // declare imaginaryPart as a double variable
public:
Complex(double = 0.0, double = 0.0); // constructor prototype
// with default arguments
};
// implementation section
Complex::Complex(double real, double imag) // constructor
{
realPart = real;
imaginaryPart = imag;
cout << "Created the new complex number object "
<< realPart << " + " << imaginaryPart << "i ";
}
int main()
{
Complex a; // declare an object
Complex b(6.8, 9.7); // declare an object
return 0;
}
Explanation / Answer
int main()
{
Complex a; // declare an object
Complex b(6.8, 9.7); // declare an object
Complex c(5.3,8.4);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.